CS Theory
Longest Substring Without Repeating Characters
A dynamic programming solution to find the longest substring without repeating characters. The algorithm tracks character positions and maintains current length while avoiding repeated characters within the sliding window.
February 5, 2026
Longest Univalue Path in Binary Tree
Solve the longest univalue path problem in binary trees using two different recursive approaches. The first involves multiple traversals while the second optimizes with bottom-up counting that processes each node only once.
February 5, 2026
Lowest Common Ancestor in Binary Trees
Two approaches to find the lowest common ancestor of two nodes in a binary tree. The first uses explicit searching with O(n²) complexity. The second achieves O(n) time through recursive traversal that returns matching nodes up the call stack.
February 5, 2026
Maximum Product Subarray
Finding the maximum product of any contiguous subarray requires tracking both minimum and maximum values at each position since negative numbers can flip signs and turn small negatives into large positives.
February 5, 2026
Maximum Sum of Two Non-Overlapping Subarrays
Find the maximum sum of two non-overlapping subarrays with given lengths. The solution handles both cases where the longer interval comes first or second by fixing one interval and searching for the optimal second interval.
February 5, 2026
Minimum ASCII Delete Sum for Two Strings
Solve the problem of finding the minimum ASCII sum of deleted characters needed to make two strings equal using dynamic programming with clear state transitions and implementation.
February 5, 2026
Minimum Cost for Tickets: A Dynamic Programming Approach
Solving the classic dynamic programming problem of finding minimum ticket costs for travel days using 1-day, 7-day, and 30-day passes with an efficient map-based approach.
February 5, 2026
Next Greater Element II: Two Approaches
Solving the circular array problem with brute force and optimized stack approaches. The first method uses O(N²) time complexity while the second achieves O(N) using a stack with bitset optimization for space efficiency.
February 5, 2026
Palindromic Substrings
Two approaches to count palindromic substrings in a string. Dynamic programming solution using 2D array and center expansion method with O(n²) time complexity.
February 5, 2026
Pancake Sorting: Flip Your Way to Order
A simple approach to pancake sorting by flipping the largest elements into place. The solution uses STL functions and demonstrates how to sort an array when you can only reverse prefixes.
February 5, 2026