Longest Bitonic Subsequence Explained - Forward + Backward LIS
Learn the Longest Bitonic Subsequence: the longest run that strictly rises then strictly falls. Combine a forward LIS and a backward LIS in O(n²) with interactive visualization.
In-depth guides on algorithms and data structures
47 posts
Learn the Longest Bitonic Subsequence: the longest run that strictly rises then strictly falls. Combine a forward LIS and a backward LIS in O(n²) with interactive visualization.
Learn how to find the start of a circular gas-station tour in O(n) with greedy. Understand diff accumulation and why moving the start forward is safe, with interactive visualization.
Learn prefix sums through a neighborhood library visitor dataset. By precomputing a prefix sum array, any range [l, r] sum is answered in O(1) with a single subtraction prefix[r+1] - prefix[l]. See the full walkthrough in AlgoNote visualization.
Learn multi-key comparison sorting that orders (x, y) coordinates by x ascending, then y ascending on ties. See how to write the comparator and watch it run with AlgoNote visualization.
Find the minimum number of operations to reduce an integer X to 1 using ÷3, ÷2, and −1. Learn why greedy fails and how the dp[i]=1+min(...) recurrence guarantees the optimum, with an interactive visualization.
Learn how to find the minimum number of moves (transfers) from start to destination on an unweighted route graph using BFS level traversal. See the queue and distance array in action with AlgoNote visualization.
Find the maximum equal piece length that cuts cables of varying lengths into at least K pieces, using binary search on the answer plus a feasibility count. Follow it step by step with AlgoNote visualization.
Learn how to count tilings of a 2-by-n strip with 1x2 and 2x1 tiles using the recurrence dp[i]=dp[i-1]+dp[i-2]. The same structure as Fibonacci, with interactive visualization on AlgoNote.
Learn how to repeatedly remove a pattern from a string in O(n) using a stack. See the key idea of comparing only the tail with AlgoNote visualization.
Find the pair whose sum is closest to a target in a sorted sequence, told through a duet pitch-matching story. Grasp the core idea of replacing the O(n²) all-pairs check with an O(n) two-pointer sweep. See the full solution in AlgoNote step-by-step visualization.
Learn parametric search through a dessert shop tasting-corner problem. Instead of picking where to cut, you binary-search the blade height (the answer) itself. See the full step-by-step solution in AlgoNote visualization.
Learn what a doubly linked list is and how it differs from a singly linked list (reverse traversal, O(1) deletion). See the core approach to handling prev/next pointers with AlgoNote visualization.
The familiar rule "keep only a few recently used apps in memory" is actually an LRU cache. We grasp why an array or a hash map alone falls short, and why combining a hash map with a doubly linked list makes every operation O(1). See the full step-by-step solution in AlgoNote visualization.
Grasp the core idea of the segment tree for fast "range sums" on an array whose values change often. We explain why prefix sums fall short and why grouping ranges into a tree works. See the full step-by-step solution in AlgoNote visualization.
What is the largest number you can build from [3, 30, 34, 5, 9]? Ordering by numeric value is wrong. The key is the "a+b vs b+a" custom comparison. Grasp why we compare this way and how to approach it. See the full step-by-step solution in AlgoNote visualization.
Grasp the core idea of solving "how many days until a warmer day?" in O(n) with a monotonic stack. We explain why a stack beats the O(n²) double loop. See the full step-by-step solution in AlgoNote visualization.
Grasp the core idea of the Minimum Spanning Tree (MST) through Prim's algorithm. Start from one node and use a priority queue to pick the cheapest connecting edge — and see how it differs from Dijkstra. Watch the full step-by-step trace in AlgoNote visualization.
Through an arm-wrestling tournament where only some results are known, learn a fresh use of Floyd-Warshall: how many players have a fully fixed rank? Instead of shortest distances, you fill a "win/loss reachability" matrix. See the full step-by-step solution in AlgoNote visualization.
When customers rush a cafe all at once, which order should you make first to minimize everyone’s total wait? Grasp the intuition behind a greedy that boils down to one line of sorting. See the full step-by-step solution in AlgoNote visualization.
Why is insertion sort sometimes slow? Shell sort fixes that weakness with the idea of a "gap" — ordering far-apart elements first. Grasp why a gap helps and how to approach it. See the full step-by-step solution in AlgoNote visualization.
Grasp the core idea of parametric search through an EV charger placement problem. Instead of choosing positions, you binary-search the answer itself. See the full step-by-step solution in AlgoNote visualization.
Understand the partition step at the heart of quick sort and why it averages O(n log n) but can degrade to O(n²). See pivot choice and in-place sorting step by step with interactive visualization.
Learn how merge sort splits the array in half, sorts each part, and merges two sorted halves — why it guarantees O(n log n) and why it is stable. Watch the merge step with interactive visualization.
Learn how KMP reuses already-compared information via a failure function (partial-match table) to find a pattern in O(n+m) without ever rewinding the text pointer. See the difference from naive search with interactive visualization.
Learn how a heap represents a complete binary tree in an array to insert and remove the min (or max) in O(log n). See sift-up/down and priority-queue use with interactive visualization.
Learn how a queue works as FIFO and how a circular buffer makes enqueue/dequeue O(1). See the difference from a stack and its use in BFS with interactive visualization.
Learn how N-Queens is solved by placing one queen per row in a safe column and backtracking when stuck, with pruning by column and diagonal usage. See the backtracking with interactive visualization.
Learn how a hash table maps keys to indices via a hash function for average O(1) operations, and how collisions are handled with chaining or open addressing. See load factor and rehashing with interactive visualization.
Learn how union-find manages groups of elements and runs union/find in near O(1) using path compression and union by rank. See both optimizations with interactive visualization.
Learn that LIS finds the length of the longest increasing subsequence, with both the O(n²) DP and the binary-search O(n log n) approach (the tails array). See the difference with interactive visualization.
Learn how to solve 0/1 knapsack in O(nW) with the dp[i][w] state and a take/leave recurrence. See the 1D optimization and common pitfalls with interactive visualization.
Learn how LCS finds the longest order-preserving common subsequence of two sequences in O(mn) with a dp[i][j] recurrence. See the difference from substrings and backtracking recovery with interactive visualization.
Learn why greedy fails on coin change and how the dp[a] = fewest coins for amount a recurrence solves it in O(amount × coins). See unreachable handling and common pitfalls with interactive visualization.
Learn how the sliding window slides a contiguous range one step at a time — adding the entering value and subtracting the leaving one — to maintain window sums/maxes in O(n). See fixed vs variable windows with interactive visualization.
Learn how two pointers move two indices over a sorted array to solve problems like two-sum in O(n), and why monotonicity guarantees no answer is missed. See it with interactive visualization.
Learn how the Sieve of Eratosthenes finds all primes up to N in O(N log log N) by crossing out multiples. See why you start at p² and stop at √N with interactive visualization.
Learn how topological sort orders vertices of a DAG so every edge u→v has u before v, using the in-degree-based Kahn’s algorithm. See cycle detection with interactive visualization.
Learn how DFS dives deep then backtracks, how to implement it with a stack or recursion, and how it differs from BFS. See why marking visited matters with interactive visualization.
Learn that preorder, inorder, and postorder differ only in "when you visit the root," why inorder gives ascending order on a BST, and how level-order (BFS) works. See it with interactive visualization.
Learn how the Euclidean algorithm computes the GCD in O(log) via gcd(a,b)=gcd(b, a mod b), why it works, and how to get the LCM from the GCD. See the remainder shrink step by step with interactive visualization.
Learn how heap sort builds a max-heap and repeatedly moves the root (max) to the end. Understand heapify and why it is always O(n log n) and in-place, with interactive visualization.
Compare the principles and time complexities of 7 major sorting algorithms, from Bubble Sort to Counting Sort. Experience each algorithm with interactive visualizations.
Learn how binary search works, its implementation, and O(log n) time complexity. A must-know algorithm for coding interviews with interactive visualization.
Understand how BFS (Breadth-First Search) works, its queue-based implementation, and differences from DFS. Master this essential graph algorithm for shortest path problems with interactive visualization.
Learn how Dijkstra's algorithm finds the shortest path in weighted graphs. Understand priority queue implementation, time complexity, and common interview patterns with step-by-step visualization.
Understand dynamic programming through the Fibonacci sequence. Learn memoization vs tabulation, how DP reduces time complexity from O(2^n) to O(n), with interactive visualization.
Master the Stack data structure: LIFO principle, push/pop operations, and real-world applications. From parentheses matching to browser history — learn with interactive visualization.