{
  "schema_version": 1,
  "source_commit": "3965a8dd",
  "problems": [
    {
      "slug": "best-time-to-buy-and-sell-stock",
      "title": "Best Time to Buy and Sell Stock",
      "level": "beginner",
      "difficulty": "easy",
      "topics": [
        "array",
        "greedy"
      ],
      "sheets": [
        "blind-75",
        "neetcode-150",
        "striver-sde",
        "babbar-450"
      ],
      "companies": [],
      "source": "https://leetcode.com/problems/best-time-to-buy-and-sell-stock/",
      "complexity": {
        "time": "O(n)",
        "space": "O(1)"
      },
      "statement": "`prices[i]` is the price of a stock on day `i`. Buy on one day and sell on a later day. Return the maximum profit, or `0` if no profit is possible.",
      "io_format": "Line 1: `prices` (space-separated). Output: the maximum profit.",
      "hints": [
        "For every buy day, try every later sell day and keep the best difference: `O(n^2)`.",
        "The best sale on day `i` uses the cheapest price seen on days `0..i-1`. Scan once, tracking the minimum price so far and the best `price - min_so_far`."
      ],
      "going_deeper": "- This is the 'maximum difference with order constraint' pattern; it is also Kadane's algorithm on the array of daily differences.\n- Variants: unlimited transactions (sum every positive difference), at most `k` transactions (DP over `k`), cooldown or fee (state machine DP).\n- For a stream of prices, the two running values are all the state you need.",
      "tests_count": 6,
      "example": {
        "input": "7 1 5 3 6 4\n",
        "expected": "5\n"
      },
      "path": "content/dsa/problems/best-time-to-buy-and-sell-stock",
      "solutions": {
        "cpp": "content/dsa/problems/best-time-to-buy-and-sell-stock/solution.cpp",
        "python": "content/dsa/problems/best-time-to-buy-and-sell-stock/solution.py",
        "java": "content/dsa/problems/best-time-to-buy-and-sell-stock/Solution.java"
      }
    },
    {
      "slug": "binary-search",
      "title": "Binary Search",
      "level": "beginner",
      "difficulty": "easy",
      "topics": [
        "array",
        "binary-search"
      ],
      "sheets": [
        "neetcode-150"
      ],
      "companies": [],
      "source": "https://leetcode.com/problems/binary-search/",
      "complexity": {
        "time": "O(log n)",
        "space": "O(1)"
      },
      "statement": "Given a sorted array of distinct integers and a target, return the index of the target or `-1` if it is absent. The algorithm must run in `O(log n)`.",
      "io_format": "Line 1: `nums`, sorted ascending with distinct values (may be empty). Line 2: `target`. Output: its index, or `-1`.",
      "hints": [
        "Scan every element (`O(n)`). That ignores the fact that the array is sorted.",
        "Keep an inclusive range `[lo, hi]` that must contain the target if it exists. Compare the middle element: equal means found; smaller means the target is to the right (`lo = mid + 1`); larger means it is to the left (`hi = mid - 1`). Two details: the loop runs while `lo <= hi` (a one-element range still needs checking), and the middle is `lo + (hi - lo) / 2` to avoid integer overflow."
      ],
      "going_deeper": "- The same loop with a different invariant finds the first position `>= target` (lower bound), which is what most real uses need (insert position, counting occurrences, range queries).\n- Binary search works on any monotonic predicate, not just arrays: 'binary search on the answer' (Koko eating bananas, ship capacity, aggressive cows).\n- On disk or over the network, B-trees and interpolation/exponential search reduce the number of expensive probes.",
      "tests_count": 7,
      "example": {
        "input": "-1 0 3 5 9 12\n9\n",
        "expected": "4\n"
      },
      "path": "content/dsa/problems/binary-search",
      "solutions": {
        "cpp": "content/dsa/problems/binary-search/solution.cpp",
        "python": "content/dsa/problems/binary-search/solution.py",
        "java": "content/dsa/problems/binary-search/Solution.java"
      }
    },
    {
      "slug": "climbing-stairs",
      "title": "Climbing Stairs",
      "level": "beginner",
      "difficulty": "easy",
      "topics": [
        "dynamic-programming",
        "math"
      ],
      "sheets": [
        "blind-75",
        "neetcode-150"
      ],
      "companies": [],
      "source": "https://leetcode.com/problems/climbing-stairs/",
      "complexity": {
        "time": "O(n)",
        "space": "O(1)"
      },
      "statement": "You climb a staircase of `n` steps taking 1 or 2 steps at a time. In how many distinct ways can you reach the top?",
      "io_format": "Line 1: `n` (0 <= n <= 90). Output: the number of ways.",
      "hints": [
        "The last move was either a 1-step from stair `n-1` or a 2-step from stair `n-2`, so `ways(n) = ways(n-1) + ways(n-2)`. Plain recursion recomputes the same values over and over: `O(2^n)`.",
        "Compute the values bottom-up. Only the previous two values are ever needed, so two variables replace the whole table. `ways(0) = 1` (one way to stay put) and `ways(1) = 1`."
      ],
      "going_deeper": "- These are the Fibonacci numbers; matrix exponentiation or fast doubling gives `O(log n)`.\n- The result overflows 32 bits at `n = 46` and 64 bits at `n = 92`, which is why real problems ask for the answer modulo a prime.\n- Generalisation: steps from a set `S` gives `ways(n) = sum(ways(n - s))`, the unbounded 'count compositions' DP.",
      "tests_count": 7,
      "example": {
        "input": "2\n",
        "expected": "2\n"
      },
      "path": "content/dsa/problems/climbing-stairs",
      "solutions": {
        "cpp": "content/dsa/problems/climbing-stairs/solution.cpp",
        "python": "content/dsa/problems/climbing-stairs/solution.py",
        "java": "content/dsa/problems/climbing-stairs/Solution.java"
      }
    },
    {
      "slug": "coin-change",
      "title": "Coin Change",
      "level": "intermediate",
      "difficulty": "medium",
      "topics": [
        "dynamic-programming"
      ],
      "sheets": [
        "blind-75",
        "neetcode-150",
        "babbar-450"
      ],
      "companies": [],
      "source": "https://leetcode.com/problems/coin-change/",
      "complexity": {
        "time": "O(amount * coins)",
        "space": "O(amount)"
      },
      "statement": "Given coin denominations (unlimited supply of each) and an amount, return the fewest coins that make up the amount, or `-1` if it cannot be made.",
      "io_format": "Line 1: the coin denominations. Line 2: `amount`. Output: the fewest coins needed, or `-1`.",
      "hints": [
        "Greedy 'largest coin first' is wrong in general: with coins `[1, 3, 4]` and amount `6` greedy gives `4+1+1` (3 coins) but `3+3` uses 2. Trying every combination recursively is exponential.",
        "Let `dp[a]` be the fewest coins for amount `a`, with `dp[0] = 0`. For every amount from 1 upward, try each coin `c <= a`: `dp[a] = min(dp[a], dp[a - c] + 1)`. Use a sentinel larger than any real answer (`amount + 1`) for 'impossible'."
      ],
      "going_deeper": "- This is the unbounded knapsack / shortest path in a graph where amounts are nodes; BFS from 0 finds the same answer.\n- Counting the number of ways (Coin Change II) needs the coin loop on the outside to avoid counting permutations.\n- Greedy is optimal only for 'canonical' coin systems such as most real currencies.",
      "tests_count": 6,
      "example": {
        "input": "1 2 5\n11\n",
        "expected": "3\n"
      },
      "path": "content/dsa/problems/coin-change",
      "solutions": {
        "cpp": "content/dsa/problems/coin-change/solution.cpp",
        "python": "content/dsa/problems/coin-change/solution.py",
        "java": "content/dsa/problems/coin-change/Solution.java"
      }
    },
    {
      "slug": "container-with-most-water",
      "title": "Container With Most Water",
      "level": "intermediate",
      "difficulty": "medium",
      "topics": [
        "array",
        "two-pointers",
        "greedy"
      ],
      "sheets": [
        "blind-75",
        "neetcode-150"
      ],
      "companies": [],
      "source": "https://leetcode.com/problems/container-with-most-water/",
      "complexity": {
        "time": "O(n)",
        "space": "O(1)"
      },
      "statement": "`height[i]` is the height of a vertical line at position `i`. Choose two lines that, together with the x-axis, hold the most water and return that area (`width x min(height)`).",
      "io_format": "Line 1: `height`. Output: the maximum area.",
      "hints": [
        "Try every pair of lines: `O(n^2)`.",
        "Start with the widest container (first and last line). The area is limited by the shorter line; moving the taller line inward can only reduce the width without raising the limit, so it can never help. Therefore always move the pointer at the **shorter** line inward, tracking the best area."
      ],
      "going_deeper": "- Proof sketch: when the shorter line is at `i`, every container `(i, k)` with `k < j` has width smaller and height at most `height[i]`, so `(i, j)` is the best container that uses `i` and `i` can be discarded.\n- Do not confuse with Trapping Rain Water, where every bar holds water above it.",
      "tests_count": 6,
      "example": {
        "input": "1 8 6 2 5 4 8 3 7\n",
        "expected": "49\n"
      },
      "path": "content/dsa/problems/container-with-most-water",
      "solutions": {
        "cpp": "content/dsa/problems/container-with-most-water/solution.cpp",
        "python": "content/dsa/problems/container-with-most-water/solution.py",
        "java": "content/dsa/problems/container-with-most-water/Solution.java"
      }
    },
    {
      "slug": "contains-duplicate",
      "title": "Contains Duplicate",
      "level": "beginner",
      "difficulty": "easy",
      "topics": [
        "array",
        "hash-set"
      ],
      "sheets": [
        "blind-75",
        "neetcode-150"
      ],
      "companies": [],
      "source": "https://leetcode.com/problems/contains-duplicate/",
      "complexity": {
        "time": "O(n)",
        "space": "O(n)"
      },
      "statement": "Return `true` if any value appears at least twice in `nums`, and `false` if every element is distinct.",
      "io_format": "Line 1: `nums` (may be empty). Output: `true` or `false`.",
      "hints": [
        "Compare every pair (`O(n^2)`), or sort and compare neighbours (`O(n log n)`, no extra memory if sorting in place).",
        "Insert the values into a hash set one by one; the first value that is already present is a duplicate."
      ],
      "going_deeper": "- Sorting vs hashing is a time/space trade-off; hashing also has worse constant factors and cache behaviour.\n- If values are bounded (for example `0..n`), a bitmap or in-place index marking gives `O(1)` extra space.\n- For data too large for memory, a Bloom filter answers 'probably seen' and an external sort gives the exact answer.",
      "tests_count": 5,
      "example": {
        "input": "1 2 3 1\n",
        "expected": "true\n"
      },
      "path": "content/dsa/problems/contains-duplicate",
      "solutions": {
        "cpp": "content/dsa/problems/contains-duplicate/solution.cpp",
        "python": "content/dsa/problems/contains-duplicate/solution.py",
        "java": "content/dsa/problems/contains-duplicate/Solution.java"
      }
    },
    {
      "slug": "course-schedule",
      "title": "Course Schedule",
      "level": "intermediate",
      "difficulty": "medium",
      "topics": [
        "graph",
        "topological-sort",
        "bfs"
      ],
      "sheets": [
        "blind-75",
        "neetcode-150"
      ],
      "companies": [],
      "source": "https://leetcode.com/problems/course-schedule/",
      "complexity": {
        "time": "O(V + E)",
        "space": "O(V + E)"
      },
      "statement": "There are `numCourses` courses labelled `0..numCourses-1` and a list of prerequisite pairs. Decide whether it is possible to finish all courses, i.e. whether the prerequisite graph has no cycle.",
      "io_format": "Line 1: `numCourses`. Line 2: the number of prerequisite pairs `p`. Next `p` lines: `a b`, meaning course `b` must be taken before course `a`. Output: `true` if all courses can be finished.",
      "hints": [
        "You can take a course once all its prerequisites are done. Courses with no prerequisites can be taken immediately; taking them may unlock others. If you get stuck with courses remaining, they depend on each other in a cycle.",
        "Kahn's algorithm. Build the graph `b -> a` and count incoming edges (in-degree) for every course. Put all courses with in-degree 0 in a queue. Repeatedly remove a course, count it, and decrement the in-degree of the courses it unlocks, queueing any that reach 0. All courses can be finished exactly when the number removed equals `numCourses`."
      ],
      "going_deeper": "- DFS with three colours (unvisited / in progress / done) detects a back edge and is the usual alternative; it also yields a topological order in reverse finishing order.\n- The order of removal is a valid schedule (Course Schedule II). Using a priority queue gives the lexicographically smallest one.\n- Build systems, package managers and spreadsheet recalculation are all topological sorts with cycle detection.",
      "tests_count": 7,
      "example": {
        "input": "2\n1\n1 0\n",
        "expected": "true\n"
      },
      "path": "content/dsa/problems/course-schedule",
      "solutions": {
        "cpp": "content/dsa/problems/course-schedule/solution.cpp",
        "python": "content/dsa/problems/course-schedule/solution.py",
        "java": "content/dsa/problems/course-schedule/Solution.java"
      }
    },
    {
      "slug": "find-minimum-in-rotated-sorted-array",
      "title": "Find Minimum in Rotated Sorted Array",
      "level": "intermediate",
      "difficulty": "medium",
      "topics": [
        "array",
        "binary-search"
      ],
      "sheets": [
        "blind-75",
        "neetcode-150"
      ],
      "companies": [],
      "source": "https://leetcode.com/problems/find-minimum-in-rotated-sorted-array/",
      "complexity": {
        "time": "O(log n)",
        "space": "O(1)"
      },
      "statement": "Find the minimum element of a rotated sorted array of distinct integers in `O(log n)`.",
      "io_format": "Line 1: `nums` (sorted, distinct, rotated between 0 and n-1 times). Output: the minimum element.",
      "hints": [
        "Scan for the smallest element: `O(n)`.",
        "Compare the middle element with the **rightmost** element of the range. If `nums[mid] > nums[hi]`, the minimum is strictly to the right of `mid` (`lo = mid + 1`). Otherwise `mid` could itself be the minimum, so keep it (`hi = mid`). The loop stops when `lo == hi`, which is the answer."
      ],
      "going_deeper": "- Comparing with `nums[lo]` instead does not work on an array that is not rotated at all; comparing with `nums[hi]` handles that case naturally.\n- With duplicates, when `nums[mid] == nums[hi]` do `hi--`; worst case `O(n)`.\n- The index found is the rotation count, which lets you map any index back to the sorted order.",
      "tests_count": 6,
      "example": {
        "input": "3 4 5 1 2\n",
        "expected": "1\n"
      },
      "path": "content/dsa/problems/find-minimum-in-rotated-sorted-array",
      "solutions": {
        "cpp": "content/dsa/problems/find-minimum-in-rotated-sorted-array/solution.cpp",
        "python": "content/dsa/problems/find-minimum-in-rotated-sorted-array/solution.py",
        "java": "content/dsa/problems/find-minimum-in-rotated-sorted-array/Solution.java"
      }
    },
    {
      "slug": "group-anagrams",
      "title": "Group Anagrams",
      "level": "intermediate",
      "difficulty": "medium",
      "topics": [
        "string",
        "hash-map",
        "sorting"
      ],
      "sheets": [
        "blind-75",
        "neetcode-150"
      ],
      "companies": [],
      "source": "https://leetcode.com/problems/group-anagrams/",
      "complexity": {
        "time": "O(n * k log k)",
        "space": "O(n * k)"
      },
      "statement": "Group the given words so that words which are anagrams of each other are together.",
      "io_format": "Line 1: the words (space-separated, lowercase). Output: one group per line. Words inside a group are sorted, and groups are sorted by their first word, so the output is unique.",
      "hints": [
        "Compare every pair of words with an anagram check and merge them into groups: `O(n^2 * k)`.",
        "All anagrams share the same sorted spelling. Use the sorted word as a hash-map key and append each word to its key's list."
      ],
      "going_deeper": "- A 26-count tuple as the key removes the `log k` factor (`O(n * k)`).\n- At scale this is a group-by-key job: the signature is the shuffle key in MapReduce/Spark.\n- LeetCode accepts any order; this repository fixes an order so that the tests are deterministic.",
      "tests_count": 5,
      "example": {
        "input": "eat tea tan ate nat bat\n",
        "expected": "ate eat tea\nbat\nnat tan\n"
      },
      "path": "content/dsa/problems/group-anagrams",
      "solutions": {
        "cpp": "content/dsa/problems/group-anagrams/solution.cpp",
        "python": "content/dsa/problems/group-anagrams/solution.py",
        "java": "content/dsa/problems/group-anagrams/Solution.java"
      }
    },
    {
      "slug": "house-robber",
      "title": "House Robber",
      "level": "intermediate",
      "difficulty": "medium",
      "topics": [
        "dynamic-programming",
        "array"
      ],
      "sheets": [
        "blind-75",
        "neetcode-150"
      ],
      "companies": [],
      "source": "https://leetcode.com/problems/house-robber/",
      "complexity": {
        "time": "O(n)",
        "space": "O(1)"
      },
      "statement": "Houses in a row each hold some money. You cannot rob two adjacent houses. Return the maximum amount you can rob.",
      "io_format": "Line 1: `nums`, the money in each house (may be empty). Output: the maximum amount.",
      "hints": [
        "For each house decide rob / skip and try all combinations (`O(2^n)`). Greedy 'take every other house' fails: for `[2, 1, 1, 2]` the best is houses 0 and 3 (total 4).",
        "Let `best(i)` be the answer for the first `i` houses. For house `i` either skip it (`best(i-1)`) or rob it and add the best of the houses before its neighbour (`best(i-2) + nums[i]`). Keep only the last two values."
      ],
      "going_deeper": "- Circular street (House Robber II): solve the line twice, once without the first house and once without the last.\n- On a tree (House Robber III): return a pair (rob this node, skip this node) from each subtree.\n- General form: maximum-weight independent set, easy on paths and trees, NP-hard on general graphs.",
      "tests_count": 6,
      "example": {
        "input": "1 2 3 1\n",
        "expected": "4\n"
      },
      "path": "content/dsa/problems/house-robber",
      "solutions": {
        "cpp": "content/dsa/problems/house-robber/solution.cpp",
        "python": "content/dsa/problems/house-robber/solution.py",
        "java": "content/dsa/problems/house-robber/Solution.java"
      }
    },
    {
      "slug": "invert-binary-tree",
      "title": "Invert Binary Tree",
      "level": "beginner",
      "difficulty": "easy",
      "topics": [
        "tree",
        "dfs"
      ],
      "sheets": [
        "blind-75",
        "neetcode-150",
        "babbar-450"
      ],
      "companies": [],
      "source": "https://leetcode.com/problems/invert-binary-tree/",
      "complexity": {
        "time": "O(n)",
        "space": "O(h)"
      },
      "statement": "Invert a binary tree: swap the left and right child of every node. (The tests print the pre-order traversal of the result.)",
      "io_format": "Line 1: the tree in level order with `null` for missing children. Output: the **pre-order traversal** of the inverted tree (empty line for an empty tree).",
      "hints": [
        "Inverting a tree means mirroring it. Mirror the root by swapping its two children; the subtrees then need the same treatment.",
        "Recursively: swap the children of the current node, then invert each child. The order (swap before or after recursing) does not matter as long as every node is swapped exactly once."
      ],
      "going_deeper": "- An explicit stack or queue avoids recursion-depth limits on skewed trees.\n- Two trees are mirror images exactly when one equals the inversion of the other; that observation solves Symmetric Tree.",
      "tests_count": 6,
      "example": {
        "input": "4 2 7 1 3 6 9\n",
        "expected": "4 7 9 6 2 3 1\n"
      },
      "path": "content/dsa/problems/invert-binary-tree",
      "solutions": {
        "cpp": "content/dsa/problems/invert-binary-tree/solution.cpp",
        "python": "content/dsa/problems/invert-binary-tree/solution.py",
        "java": "content/dsa/problems/invert-binary-tree/Solution.java"
      }
    },
    {
      "slug": "longest-increasing-subsequence",
      "title": "Longest Increasing Subsequence",
      "level": "intermediate",
      "difficulty": "medium",
      "topics": [
        "dynamic-programming",
        "binary-search"
      ],
      "sheets": [
        "blind-75",
        "neetcode-150",
        "striver-sde",
        "babbar-450"
      ],
      "companies": [],
      "source": "https://leetcode.com/problems/longest-increasing-subsequence/",
      "complexity": {
        "time": "O(n log n)",
        "space": "O(n)"
      },
      "statement": "Return the length of the longest strictly increasing subsequence of `nums` (elements need not be adjacent).",
      "io_format": "Line 1: `nums` (may be empty). Output: the length of the longest strictly increasing subsequence.",
      "hints": [
        "`dp[i]` = length of the longest increasing subsequence ending at `i` = 1 + the best `dp[j]` over earlier `j` with `nums[j] < nums[i]`. That is `O(n^2)`.",
        "Maintain `tails`, where `tails[k]` is the smallest possible last value of an increasing subsequence of length `k+1`. `tails` is always sorted. For each number, binary-search the first entry `>= x`: replace it with `x` (a better, smaller tail), or append `x` if every entry is smaller. The answer is the length of `tails`. Note that `tails` is generally **not** an actual subsequence, only its length is meaningful."
      ],
      "going_deeper": "- Use 'first entry `> x`' (upper bound) instead to get the longest non-decreasing subsequence.\n- To reconstruct a subsequence, store for each element the index of its predecessor.\n- Related: Russian Doll Envelopes (sort then LIS), patience sorting, and Dilworth's theorem (minimum number of decreasing sequences covering the array).",
      "tests_count": 7,
      "example": {
        "input": "10 9 2 5 3 7 101 18\n",
        "expected": "4\n"
      },
      "path": "content/dsa/problems/longest-increasing-subsequence",
      "solutions": {
        "cpp": "content/dsa/problems/longest-increasing-subsequence/solution.cpp",
        "python": "content/dsa/problems/longest-increasing-subsequence/solution.py",
        "java": "content/dsa/problems/longest-increasing-subsequence/Solution.java"
      }
    },
    {
      "slug": "longest-palindromic-substring",
      "title": "Longest Palindromic Substring",
      "level": "intermediate",
      "difficulty": "medium",
      "topics": [
        "string",
        "two-pointers",
        "dynamic-programming"
      ],
      "sheets": [
        "blind-75",
        "neetcode-150",
        "babbar-450"
      ],
      "companies": [],
      "source": "https://leetcode.com/problems/longest-palindromic-substring/",
      "complexity": {
        "time": "O(n^2)",
        "space": "O(1)"
      },
      "statement": "Return the longest substring of `s` that reads the same forwards and backwards.",
      "io_format": "Line 1: `s` (non-empty). Output: the longest palindromic substring; if several have the same length, the one that starts first.",
      "hints": [
        "Check every substring with a palindrome test: `O(n^3)`.",
        "Every palindrome has a centre: a single character (odd length) or the gap between two characters (even length). For each of the `2n - 1` centres, expand outward while the two ends match and keep the longest span. Updating only on a strictly longer span keeps the earliest answer on ties."
      ],
      "going_deeper": "- Manacher's algorithm reuses previously computed spans to reach `O(n)`.\n- The `dp[i][j]` formulation costs `O(n^2)` memory but extends to counting palindromic substrings and to palindrome partitioning.\n- Longest palindromic *subsequence* is a different problem (LCS of the string with its reverse).",
      "tests_count": 7,
      "example": {
        "input": "babad\n",
        "expected": "bab\n"
      },
      "path": "content/dsa/problems/longest-palindromic-substring",
      "solutions": {
        "cpp": "content/dsa/problems/longest-palindromic-substring/solution.cpp",
        "python": "content/dsa/problems/longest-palindromic-substring/solution.py",
        "java": "content/dsa/problems/longest-palindromic-substring/Solution.java"
      }
    },
    {
      "slug": "longest-substring-without-repeating-characters",
      "title": "Longest Substring Without Repeating Characters",
      "level": "intermediate",
      "difficulty": "medium",
      "topics": [
        "string",
        "sliding-window",
        "hash-map"
      ],
      "sheets": [
        "blind-75",
        "neetcode-150",
        "striver-sde"
      ],
      "companies": [],
      "source": "https://leetcode.com/problems/longest-substring-without-repeating-characters/",
      "complexity": {
        "time": "O(n)",
        "space": "O(min(n, alphabet))"
      },
      "statement": "Return the length of the longest substring of `s` in which no character repeats.",
      "io_format": "Line 1: `s` (may be empty; may contain spaces). Output: the length.",
      "hints": [
        "Check every substring for duplicates: `O(n^3)`, or `O(n^2)` by extending from each start until a repeat.",
        "Slide a window `[left, right]` that never contains a repeat. Store the last index of each character. When `s[right]` was last seen at an index inside the window, jump `left` to one past that index. The `max` in `left = max(left, last + 1)` matters: an old occurrence that is already outside the window must not move `left` backwards."
      ],
      "going_deeper": "- The 'shrink until valid' window with a set is also `O(n)` (each character enters and leaves once) and generalises to 'at most k distinct characters'.\n- For ASCII input a fixed 128/256-entry array is faster than a hash map.",
      "tests_count": 7,
      "example": {
        "input": "abcabcbb\n",
        "expected": "3\n"
      },
      "path": "content/dsa/problems/longest-substring-without-repeating-characters",
      "solutions": {
        "cpp": "content/dsa/problems/longest-substring-without-repeating-characters/solution.cpp",
        "python": "content/dsa/problems/longest-substring-without-repeating-characters/solution.py",
        "java": "content/dsa/problems/longest-substring-without-repeating-characters/Solution.java"
      }
    },
    {
      "slug": "maximum-depth-of-binary-tree",
      "title": "Maximum Depth of Binary Tree",
      "level": "beginner",
      "difficulty": "easy",
      "topics": [
        "tree",
        "dfs",
        "bfs"
      ],
      "sheets": [
        "blind-75",
        "neetcode-150",
        "striver-sde",
        "babbar-450"
      ],
      "companies": [],
      "source": "https://leetcode.com/problems/maximum-depth-of-binary-tree/",
      "complexity": {
        "time": "O(n)",
        "space": "O(h)"
      },
      "statement": "Return the maximum depth of a binary tree: the number of nodes on the longest path from the root down to a leaf.",
      "io_format": "Line 1: the tree in level order with `null` for missing children (LeetCode format; empty line = empty tree). Output: the depth.",
      "hints": [
        "The depth of a tree is 1 (the root) plus the depth of its deeper subtree. An empty tree has depth 0.",
        "Translate the definition directly into recursion: `depth(node) = 0` if the node is null, otherwise `1 + max(depth(left), depth(right))`. Every node is visited once."
      ],
      "going_deeper": "- Recursion depth equals the tree height `h`; on a degenerate (linked-list shaped) tree that is `n` and can overflow the call stack. An iterative BFS counting levels uses `O(width)` memory instead.\n- The same post-order shape (combine the children's answers) solves diameter, balanced-tree check and maximum path sum.",
      "tests_count": 5,
      "example": {
        "input": "3 9 20 null null 15 7\n",
        "expected": "3\n"
      },
      "path": "content/dsa/problems/maximum-depth-of-binary-tree",
      "solutions": {
        "cpp": "content/dsa/problems/maximum-depth-of-binary-tree/solution.cpp",
        "python": "content/dsa/problems/maximum-depth-of-binary-tree/solution.py",
        "java": "content/dsa/problems/maximum-depth-of-binary-tree/Solution.java"
      }
    },
    {
      "slug": "maximum-subarray",
      "title": "Maximum Subarray (Kadane's Algorithm)",
      "level": "beginner",
      "difficulty": "easy",
      "topics": [
        "array",
        "dynamic-programming"
      ],
      "sheets": [
        "blind-75",
        "neetcode-150",
        "striver-sde",
        "babbar-450"
      ],
      "companies": [],
      "source": "https://leetcode.com/problems/maximum-subarray/",
      "complexity": {
        "time": "O(n)",
        "space": "O(1)"
      },
      "statement": "Find the contiguous non-empty subarray with the largest sum and return that sum.",
      "io_format": "Line 1: `nums` (at least one number). Output: the largest sum of a non-empty contiguous subarray.",
      "hints": [
        "Compute the sum of every subarray `nums[i..j]` with two loops (extend `j` and keep a running sum): `O(n^2)`.",
        "Let `cur` be the best sum of a subarray that ends exactly at the current element. Either extend the previous subarray or start fresh: `cur = max(x, cur + x)`. The answer is the largest `cur` seen. Initialise with the first element, not `0`, so that an all-negative array returns its largest element."
      ],
      "going_deeper": "- To return the subarray itself, remember where the current run started and update the best `(start, end)` when the best sum improves.\n- Divide and conquer gives `O(n log n)` and generalises to a segment tree that answers range maximum-subarray queries with updates.\n- Sums can exceed 32 bits; the reference solutions accumulate in 64 bits.",
      "tests_count": 6,
      "example": {
        "input": "-2 1 -3 4 -1 2 1 -5 4\n",
        "expected": "6\n"
      },
      "path": "content/dsa/problems/maximum-subarray",
      "solutions": {
        "cpp": "content/dsa/problems/maximum-subarray/solution.cpp",
        "python": "content/dsa/problems/maximum-subarray/solution.py",
        "java": "content/dsa/problems/maximum-subarray/Solution.java"
      }
    },
    {
      "slug": "median-of-two-sorted-arrays",
      "title": "Median of Two Sorted Arrays",
      "level": "experienced",
      "difficulty": "hard",
      "topics": [
        "array",
        "binary-search",
        "divide-and-conquer"
      ],
      "sheets": [
        "neetcode-150",
        "striver-sde",
        "babbar-450"
      ],
      "companies": [],
      "source": "https://leetcode.com/problems/median-of-two-sorted-arrays/",
      "complexity": {
        "time": "O(log(min(m, n)))",
        "space": "O(1)"
      },
      "statement": "Given two sorted arrays, return the median of all their elements combined. The required running time is `O(log(m + n))`.",
      "io_format": "Line 1: first sorted array. Line 2: second sorted array (one of them may be empty, not both). Output: the median with one decimal place.",
      "hints": [
        "Merge the two arrays (or just walk the merge until the middle): `O(m + n)`.",
        "Split the combined data into a left half and a right half of equal size (the left gets the extra element when the total is odd). If the left half takes `i` elements from the shorter array `A`, it must take `j = half - i` from `B`. The split is correct when `A[i-1] <= B[j]` and `B[j-1] <= A[i]`. Binary-search `i` on the shorter array: if `A[i-1] > B[j]` take fewer from `A`, otherwise take more. Use minus/plus infinity for missing neighbours at the edges. The median is then the max of the left side (odd total) or the average of that and the min of the right side (even total)."
      ],
      "going_deeper": "- Searching the shorter array guarantees `j` stays in range and gives `O(log(min(m, n)))`.\n- The same partition idea finds the k-th smallest element of two sorted arrays.\n- Average with `(a + b) / 2.0` in floating point (or 64-bit) to avoid 32-bit overflow.\n- For `k` sorted arrays or streams, use heaps or a binary search on the value range instead.",
      "tests_count": 8,
      "example": {
        "input": "1 3\n2\n",
        "expected": "2.0\n"
      },
      "path": "content/dsa/problems/median-of-two-sorted-arrays",
      "solutions": {
        "cpp": "content/dsa/problems/median-of-two-sorted-arrays/solution.cpp",
        "python": "content/dsa/problems/median-of-two-sorted-arrays/solution.py",
        "java": "content/dsa/problems/median-of-two-sorted-arrays/Solution.java"
      }
    },
    {
      "slug": "merge-intervals",
      "title": "Merge Intervals",
      "level": "intermediate",
      "difficulty": "medium",
      "topics": [
        "array",
        "sorting",
        "intervals"
      ],
      "sheets": [
        "blind-75",
        "neetcode-150",
        "striver-sde",
        "babbar-450"
      ],
      "companies": [],
      "source": "https://leetcode.com/problems/merge-intervals/",
      "complexity": {
        "time": "O(n log n)",
        "space": "O(n)"
      },
      "statement": "Merge all overlapping intervals and return the non-overlapping intervals that cover the same ranges. Intervals that only touch (`[1,4]` and `[4,5]`) count as overlapping.",
      "io_format": "Line 1: `n`. Next `n` lines: `start end`. Output: the merged intervals, one per line, sorted by start.",
      "hints": [
        "Repeatedly look for any two intervals that overlap and replace them by their union until nothing changes: `O(n^2)` or worse.",
        "Sort by start. Walk through the intervals keeping the last merged interval: if the next one starts at or before the current end, extend the end to `max(end, next.end)`; otherwise start a new merged interval. Taking the `max` handles an interval that is completely contained in the previous one."
      ],
      "going_deeper": "- If intervals arrive online, keep them in an ordered map (interval tree / `std::map`) and merge on insert in `O(log n)` amortised.\n- A sweep line over +1/-1 events answers related questions: maximum overlap, meeting rooms needed.\n- With small integer endpoints, a difference array avoids sorting.",
      "tests_count": 6,
      "example": {
        "input": "4\n1 3\n2 6\n8 10\n15 18\n",
        "expected": "1 6\n8 10\n15 18\n"
      },
      "path": "content/dsa/problems/merge-intervals",
      "solutions": {
        "cpp": "content/dsa/problems/merge-intervals/solution.cpp",
        "python": "content/dsa/problems/merge-intervals/solution.py",
        "java": "content/dsa/problems/merge-intervals/Solution.java"
      }
    },
    {
      "slug": "merge-two-sorted-lists",
      "title": "Merge Two Sorted Lists",
      "level": "beginner",
      "difficulty": "easy",
      "topics": [
        "linked-list",
        "two-pointers"
      ],
      "sheets": [
        "blind-75",
        "neetcode-150",
        "striver-sde"
      ],
      "companies": [],
      "source": "https://leetcode.com/problems/merge-two-sorted-lists/",
      "complexity": {
        "time": "O(n + m)",
        "space": "O(1)"
      },
      "statement": "Merge two sorted linked lists into one sorted list by splicing together their nodes.",
      "io_format": "Line 1: first sorted list. Line 2: second sorted list (either may be empty). Output: the merged sorted list.",
      "hints": [
        "Collect all values, sort them and build a new list: `O((n+m) log(n+m))` and it ignores that the inputs are already sorted.",
        "Use a dummy head so the first node needs no special case. Repeatedly attach the smaller of the two front nodes to the tail and advance that list. When one list runs out, attach the rest of the other. Taking from the first list on ties keeps the merge stable."
      ],
      "going_deeper": "- This is the merge step of merge sort; on linked lists it needs no extra memory, which is why merge sort is the standard sort for lists.\n- Merging `k` lists: use a min-heap of the `k` fronts (`O(N log k)`) or merge pairwise.",
      "tests_count": 5,
      "example": {
        "input": "1 2 4\n1 3 4\n",
        "expected": "1 1 2 3 4 4\n"
      },
      "path": "content/dsa/problems/merge-two-sorted-lists",
      "solutions": {
        "cpp": "content/dsa/problems/merge-two-sorted-lists/solution.cpp",
        "python": "content/dsa/problems/merge-two-sorted-lists/solution.py",
        "java": "content/dsa/problems/merge-two-sorted-lists/Solution.java"
      }
    },
    {
      "slug": "number-of-islands",
      "title": "Number of Islands",
      "level": "intermediate",
      "difficulty": "medium",
      "topics": [
        "graph",
        "dfs",
        "bfs",
        "matrix"
      ],
      "sheets": [
        "blind-75",
        "neetcode-150",
        "striver-sde"
      ],
      "companies": [],
      "source": "https://leetcode.com/problems/number-of-islands/",
      "complexity": {
        "time": "O(rows * cols)",
        "space": "O(rows * cols)"
      },
      "statement": "Count the islands in a grid. An island is a group of land cells connected horizontally or vertically.",
      "io_format": "Line 1: the number of rows `r`. Next `r` lines: strings of `1` (land) and `0` (water). Output: the number of islands.",
      "hints": [
        "Every land cell belongs to exactly one island. If, on finding a land cell, you could mark its whole island as counted, then the number of times you start a new marking is the answer.",
        "Scan all cells. On an unvisited land cell, increment the count and flood-fill from it (BFS or DFS over the four neighbours), turning visited land into water so it is never counted again. The reference solutions use an explicit queue (BFS) so that a very large island cannot overflow the call stack."
      ],
      "going_deeper": "- Union-Find solves the same problem and also supports the online version (cells turning into land one at a time).\n- If the grid must not be modified, use a separate visited matrix.\n- For grids that do not fit in memory, process row by row with Union-Find over the boundary row.",
      "tests_count": 6,
      "example": {
        "input": "4\n11110\n11010\n11000\n00000\n",
        "expected": "1\n"
      },
      "path": "content/dsa/problems/number-of-islands",
      "solutions": {
        "cpp": "content/dsa/problems/number-of-islands/solution.cpp",
        "python": "content/dsa/problems/number-of-islands/solution.py",
        "java": "content/dsa/problems/number-of-islands/Solution.java"
      }
    },
    {
      "slug": "product-of-array-except-self",
      "title": "Product of Array Except Self",
      "level": "intermediate",
      "difficulty": "medium",
      "topics": [
        "array",
        "prefix-sum"
      ],
      "sheets": [
        "blind-75",
        "neetcode-150"
      ],
      "companies": [],
      "source": "https://leetcode.com/problems/product-of-array-except-self/",
      "complexity": {
        "time": "O(n)",
        "space": "O(1) extra"
      },
      "statement": "Return an array `answer` where `answer[i]` is the product of all elements of `nums` except `nums[i]`. Do it in `O(n)` without using division.",
      "io_format": "Line 1: `nums`. Output: the result array.",
      "hints": [
        "For each index multiply all the other elements: `O(n^2)`. Dividing the total product by `nums[i]` is tempting but breaks when the array contains a zero (and division is forbidden).",
        "`answer[i]` = (product of everything left of `i`) x (product of everything right of `i`). First pass: fill `answer[i]` with the prefix product. Second pass from the right: multiply by a running suffix product. The output array doubles as the prefix array, so no extra arrays are needed."
      ],
      "going_deeper": "- The same prefix/suffix decomposition answers 'aggregate of everything except me' for any associative operation (gcd, min, xor).\n- With zeros: one zero makes every entry `0` except at that index; two or more zeros make the whole answer `0`. The prefix/suffix method handles this without special cases.",
      "tests_count": 5,
      "example": {
        "input": "1 2 3 4\n",
        "expected": "24 12 8 6\n"
      },
      "path": "content/dsa/problems/product-of-array-except-self",
      "solutions": {
        "cpp": "content/dsa/problems/product-of-array-except-self/solution.cpp",
        "python": "content/dsa/problems/product-of-array-except-self/solution.py",
        "java": "content/dsa/problems/product-of-array-except-self/Solution.java"
      }
    },
    {
      "slug": "reverse-linked-list",
      "title": "Reverse Linked List",
      "level": "beginner",
      "difficulty": "easy",
      "topics": [
        "linked-list"
      ],
      "sheets": [
        "blind-75",
        "neetcode-150",
        "striver-sde",
        "babbar-450"
      ],
      "companies": [],
      "source": "https://leetcode.com/problems/reverse-linked-list/",
      "complexity": {
        "time": "O(n)",
        "space": "O(1)"
      },
      "statement": "Reverse a singly linked list and return the new head.",
      "io_format": "Line 1: the list values from head to tail (may be empty). Output: the reversed list.",
      "hints": [
        "Copy the values into an array, then write them back in reverse order. It works but uses `O(n)` extra memory and does not change the links.",
        "Walk the list once with three pointers. For each node, remember its `next`, point the node back at `prev`, then advance: `prev` becomes the current node and the current node becomes the saved `next`. When the walk ends, `prev` is the new head."
      ],
      "going_deeper": "- The recursive version is elegant but uses `O(n)` stack and can overflow on long lists.\n- The same pointer dance is the building block for reversing a sub-list, reversing in groups of `k`, and checking a palindrome list in `O(1)` space.",
      "tests_count": 5,
      "example": {
        "input": "1 2 3 4 5\n",
        "expected": "5 4 3 2 1\n"
      },
      "path": "content/dsa/problems/reverse-linked-list",
      "solutions": {
        "cpp": "content/dsa/problems/reverse-linked-list/solution.cpp",
        "python": "content/dsa/problems/reverse-linked-list/solution.py",
        "java": "content/dsa/problems/reverse-linked-list/Solution.java"
      }
    },
    {
      "slug": "search-in-rotated-sorted-array",
      "title": "Search in Rotated Sorted Array",
      "level": "intermediate",
      "difficulty": "medium",
      "topics": [
        "array",
        "binary-search"
      ],
      "sheets": [
        "blind-75",
        "neetcode-150",
        "striver-sde",
        "babbar-450"
      ],
      "companies": [],
      "source": "https://leetcode.com/problems/search-in-rotated-sorted-array/",
      "complexity": {
        "time": "O(log n)",
        "space": "O(1)"
      },
      "statement": "A sorted array of distinct integers has been rotated (for example `[0,1,2,4,5,6,7]` -> `[4,5,6,7,0,1,2]`). Find the index of `target` in `O(log n)`, or return `-1`.",
      "io_format": "Line 1: `nums` (a sorted array of distinct values rotated at an unknown pivot). Line 2: `target`. Output: its index or `-1`.",
      "hints": [
        "Linear scan is `O(n)`. Alternatively find the pivot first and run two ordinary binary searches.",
        "Cut the range at `mid`: at least one of the two halves is always sorted. If `nums[lo] <= nums[mid]` the left half is sorted, so check whether the target lies inside `[nums[lo], nums[mid])`; if it does search left, otherwise search right. Mirror the logic when the right half is the sorted one."
      ],
      "going_deeper": "- With duplicates (`nums[lo] == nums[mid] == nums[hi]`) you cannot tell which half is sorted; shrinking both ends by one handles it but the worst case becomes `O(n)`.\n- The `<=` in `nums[lo] <= nums[mid]` matters for two-element ranges where `lo == mid`.",
      "tests_count": 7,
      "example": {
        "input": "4 5 6 7 0 1 2\n0\n",
        "expected": "4\n"
      },
      "path": "content/dsa/problems/search-in-rotated-sorted-array",
      "solutions": {
        "cpp": "content/dsa/problems/search-in-rotated-sorted-array/solution.cpp",
        "python": "content/dsa/problems/search-in-rotated-sorted-array/solution.py",
        "java": "content/dsa/problems/search-in-rotated-sorted-array/Solution.java"
      }
    },
    {
      "slug": "sort-colors",
      "title": "Sort Colors (Dutch National Flag)",
      "level": "beginner",
      "difficulty": "easy",
      "topics": [
        "array",
        "two-pointers"
      ],
      "sheets": [
        "neetcode-150",
        "striver-sde",
        "babbar-450"
      ],
      "companies": [],
      "source": "https://leetcode.com/problems/sort-colors/",
      "complexity": {
        "time": "O(n)",
        "space": "O(1)"
      },
      "statement": "Sort an array of 0s, 1s and 2s in place, in one pass, without using a library sort.",
      "io_format": "Line 1: an array containing only `0`, `1` and `2`. Output: the sorted array.",
      "hints": [
        "Count how many 0s, 1s and 2s there are, then overwrite the array (two passes).",
        "Maintain three regions with pointers `low`, `mid`, `high`: everything before `low` is 0, between `low` and `mid` is 1, after `high` is 2, and `mid..high` is unknown. Look at `nums[mid]`: a 0 is swapped to `low` (advance both), a 1 stays (advance `mid`), a 2 is swapped to `high` (shrink `high` but do **not** advance `mid`, because the swapped-in value is still unknown)."
      ],
      "going_deeper": "- This is the 3-way partition used by quicksort to handle many equal keys efficiently.\n- It generalises to partitioning around any pivot value, and to `k` colours with counting sort.",
      "tests_count": 6,
      "example": {
        "input": "2 0 2 1 1 0\n",
        "expected": "0 0 1 1 2 2\n"
      },
      "path": "content/dsa/problems/sort-colors",
      "solutions": {
        "cpp": "content/dsa/problems/sort-colors/solution.cpp",
        "python": "content/dsa/problems/sort-colors/solution.py",
        "java": "content/dsa/problems/sort-colors/Solution.java"
      }
    },
    {
      "slug": "three-sum",
      "title": "3Sum",
      "level": "intermediate",
      "difficulty": "medium",
      "topics": [
        "array",
        "two-pointers",
        "sorting"
      ],
      "sheets": [
        "blind-75",
        "neetcode-150",
        "striver-sde",
        "babbar-450"
      ],
      "companies": [],
      "source": "https://leetcode.com/problems/3sum/",
      "complexity": {
        "time": "O(n^2)",
        "space": "O(1) extra"
      },
      "statement": "Return all unique triplets `[a, b, c]` from `nums` with `a + b + c = 0`. The result must not contain duplicate triplets.",
      "io_format": "Line 1: `nums`. Output: one triplet per line, each in ascending order, triplets in lexicographic order. No output lines if there is none.",
      "hints": [
        "Three nested loops over all triples, with a set to remove duplicates: `O(n^3)`.",
        "Sort the array. Fix the smallest element `nums[i]`, then find pairs in the remainder that sum to `-nums[i]` with two pointers moving inward. Skip equal neighbours for `i` and, after recording a triplet, for both pointers; that removes duplicates without a set. Stop early once `nums[i] > 0`."
      ],
      "going_deeper": "- Fixing one element reduces k-Sum to (k-1)-Sum; the base case is the two-pointer 2-Sum, giving `O(n^(k-1))`.\n- 3Sum is believed to need about `n^2` time in general; many geometry problems are '3SUM-hard'.\n- Use 64-bit sums if values can approach the 32-bit limit.",
      "tests_count": 6,
      "example": {
        "input": "-1 0 1 2 -1 -4\n",
        "expected": "-1 -1 2\n-1 0 1\n"
      },
      "path": "content/dsa/problems/three-sum",
      "solutions": {
        "cpp": "content/dsa/problems/three-sum/solution.cpp",
        "python": "content/dsa/problems/three-sum/solution.py",
        "java": "content/dsa/problems/three-sum/Solution.java"
      }
    },
    {
      "slug": "top-k-frequent-elements",
      "title": "Top K Frequent Elements",
      "level": "intermediate",
      "difficulty": "medium",
      "topics": [
        "array",
        "hash-map",
        "bucket-sort",
        "heap"
      ],
      "sheets": [
        "blind-75",
        "neetcode-150"
      ],
      "companies": [],
      "source": "https://leetcode.com/problems/top-k-frequent-elements/",
      "complexity": {
        "time": "O(n)",
        "space": "O(n)"
      },
      "statement": "Return the `k` most frequent elements of `nums`. The answer is guaranteed to be unique.",
      "io_format": "Line 1: `nums`. Line 2: `k`. Output: the `k` most frequent values in ascending order (the tests have a unique answer).",
      "hints": [
        "Count each value with a hash map, sort the distinct values by count and take the first `k`: `O(n log n)`.",
        "A count can only be between 1 and `n`, so bucket the values by count: `bucket[c]` holds every value that appears `c` times. Walk the buckets from `n` down to 1 and collect values until `k` are found. No comparison sort is needed, so the whole thing is `O(n)`."
      ],
      "going_deeper": "- A min-heap of size `k` gives `O(n log k)` and works on a stream.\n- Quickselect on the counts is `O(n)` average with `O(1)` extra space beyond the map.\n- For unbounded streams with limited memory, Count-Min Sketch plus a heap gives approximate heavy hitters.",
      "tests_count": 5,
      "example": {
        "input": "1 1 1 2 2 3\n2\n",
        "expected": "1 2\n"
      },
      "path": "content/dsa/problems/top-k-frequent-elements",
      "solutions": {
        "cpp": "content/dsa/problems/top-k-frequent-elements/solution.cpp",
        "python": "content/dsa/problems/top-k-frequent-elements/solution.py",
        "java": "content/dsa/problems/top-k-frequent-elements/Solution.java"
      }
    },
    {
      "slug": "trapping-rain-water",
      "title": "Trapping Rain Water",
      "level": "experienced",
      "difficulty": "hard",
      "topics": [
        "array",
        "two-pointers",
        "stack"
      ],
      "sheets": [
        "neetcode-150",
        "striver-sde",
        "babbar-450"
      ],
      "companies": [],
      "source": "https://leetcode.com/problems/trapping-rain-water/",
      "complexity": {
        "time": "O(n)",
        "space": "O(1)"
      },
      "statement": "Given an elevation map where each bar has width 1, compute how much water it traps after raining.",
      "io_format": "Line 1: `height` (may be empty). Output: total units of trapped water.",
      "hints": [
        "Water above bar `i` is `min(tallest bar to its left, tallest bar to its right) - height[i]` (never negative). Recomputing both maxima for every bar is `O(n^2)`; precomputing prefix and suffix maxima makes it `O(n)` time with `O(n)` space.",
        "Use two pointers and two running maxima. If `height[lo] < height[hi]`, then the right side is guaranteed to have a wall at least as tall as `height[lo]`, so the water above `lo` depends only on `left_max`: add `left_max - height[lo]` and advance `lo`. Otherwise do the symmetric step for `hi`. This removes the two extra arrays."
      ],
      "going_deeper": "- A monotonic stack computes the same total layer by layer (horizontal slabs) and extends to related problems like Largest Rectangle in Histogram.\n- The 2-D version (Trapping Rain Water II) needs a min-heap flood fill from the border.\n- Totals can exceed 32 bits for large inputs; the solutions accumulate in 64 bits.",
      "tests_count": 7,
      "example": {
        "input": "0 1 0 2 1 0 1 3 2 1 2 1\n",
        "expected": "6\n"
      },
      "path": "content/dsa/problems/trapping-rain-water",
      "solutions": {
        "cpp": "content/dsa/problems/trapping-rain-water/solution.cpp",
        "python": "content/dsa/problems/trapping-rain-water/solution.py",
        "java": "content/dsa/problems/trapping-rain-water/Solution.java"
      }
    },
    {
      "slug": "two-sum",
      "title": "Two Sum",
      "level": "beginner",
      "difficulty": "easy",
      "topics": [
        "array",
        "hash-map"
      ],
      "sheets": [
        "blind-75",
        "neetcode-150",
        "striver-sde"
      ],
      "companies": [],
      "source": "https://leetcode.com/problems/two-sum/",
      "complexity": {
        "time": "O(n)",
        "space": "O(n)"
      },
      "statement": "Given an array of integers `nums` and an integer `target`, return the indices of the two numbers that add up to `target`. Exactly one valid pair exists and the same element may not be used twice.",
      "io_format": "Line 1: the array `nums` (space-separated). Line 2: `target`. Output: the two indices (0-based), smaller first.",
      "hints": [
        "Try every pair `(i, j)` with two nested loops and return the first pair whose sum is `target`. This is `O(n^2)`: fine for a few hundred numbers, too slow for 10^5.",
        "While scanning left to right, the partner of `nums[i]` must be `target - nums[i]`. Keep a hash map from value to index of everything seen so far; for each element, look its partner up before inserting the element itself. Looking up *before* inserting is what prevents using the same element twice."
      ],
      "going_deeper": "- If the array is already sorted, two pointers give `O(1)` extra space.\n- If the same array is queried with many targets, build the map once.\n- When the values are huge or streamed, the map is the memory bottleneck; sorting an index array and using two pointers trades time for space.\n- `nums[i] + nums[j]` can overflow 32-bit integers in C++/Java for large inputs; compute `target - nums[i]` in 64 bits if the constraints allow it.",
      "tests_count": 5,
      "example": {
        "input": "2 7 11 15\n9\n",
        "expected": "0 1\n"
      },
      "path": "content/dsa/problems/two-sum",
      "solutions": {
        "cpp": "content/dsa/problems/two-sum/solution.cpp",
        "python": "content/dsa/problems/two-sum/solution.py",
        "java": "content/dsa/problems/two-sum/Solution.java"
      }
    },
    {
      "slug": "valid-anagram",
      "title": "Valid Anagram",
      "level": "beginner",
      "difficulty": "easy",
      "topics": [
        "string",
        "hash-map"
      ],
      "sheets": [
        "blind-75",
        "neetcode-150"
      ],
      "companies": [],
      "source": "https://leetcode.com/problems/valid-anagram/",
      "complexity": {
        "time": "O(n)",
        "space": "O(1)"
      },
      "statement": "Return `true` if `t` is an anagram of `s` (same letters with the same counts, in any order).",
      "io_format": "Line 1: `s`. Line 2: `t`. Lowercase English letters. Output: `true` or `false`.",
      "hints": [
        "Sort both strings and compare them: `O(n log n)`.",
        "If the lengths differ the answer is `false`. Otherwise count letters of `s` up and letters of `t` down in one array of 26 counters; the strings are anagrams exactly when every counter ends at zero."
      ],
      "going_deeper": "- For Unicode input use a hash map keyed by code point (and decide whether to normalise composed characters first).\n- The 26-counter vector is also a hashable signature: that is the key idea in Group Anagrams.",
      "tests_count": 5,
      "example": {
        "input": "anagram\nnagaram\n",
        "expected": "true\n"
      },
      "path": "content/dsa/problems/valid-anagram",
      "solutions": {
        "cpp": "content/dsa/problems/valid-anagram/solution.cpp",
        "python": "content/dsa/problems/valid-anagram/solution.py",
        "java": "content/dsa/problems/valid-anagram/Solution.java"
      }
    },
    {
      "slug": "valid-parentheses",
      "title": "Valid Parentheses",
      "level": "beginner",
      "difficulty": "easy",
      "topics": [
        "string",
        "stack"
      ],
      "sheets": [
        "blind-75",
        "neetcode-150",
        "striver-sde",
        "babbar-450"
      ],
      "companies": [],
      "source": "https://leetcode.com/problems/valid-parentheses/",
      "complexity": {
        "time": "O(n)",
        "space": "O(n)"
      },
      "statement": "A string of brackets is valid if every opening bracket is closed by the same type of bracket in the correct order. Decide whether the input is valid.",
      "io_format": "Line 1: a string of the characters `()[]{}` (may be empty). Output: `true` or `false`.",
      "hints": [
        "Repeatedly delete adjacent pairs `()`, `[]`, `{}` until nothing changes; the string is valid if it becomes empty. That is `O(n^2)`.",
        "The most recently opened bracket must be the first one closed: a stack. Push every opening bracket; on a closing bracket the stack must be non-empty and its top must be the matching opener. At the end the stack must be empty."
      ],
      "going_deeper": "- With a single bracket type a counter is enough; the stack is needed only because types can interleave.\n- Related: minimum removals to make valid, longest valid parentheses (DP or stack of indices), generating all valid strings (backtracking).",
      "tests_count": 8,
      "example": {
        "input": "()\n",
        "expected": "true\n"
      },
      "path": "content/dsa/problems/valid-parentheses",
      "solutions": {
        "cpp": "content/dsa/problems/valid-parentheses/solution.cpp",
        "python": "content/dsa/problems/valid-parentheses/solution.py",
        "java": "content/dsa/problems/valid-parentheses/Solution.java"
      }
    },
    {
      "slug": "word-break",
      "title": "Word Break",
      "level": "intermediate",
      "difficulty": "medium",
      "topics": [
        "dynamic-programming",
        "string",
        "hash-set"
      ],
      "sheets": [
        "blind-75",
        "neetcode-150",
        "striver-sde",
        "babbar-450"
      ],
      "companies": [],
      "source": "https://leetcode.com/problems/word-break/",
      "complexity": {
        "time": "O(n^2) substring checks",
        "space": "O(n + dictionary)"
      },
      "statement": "Return `true` if `s` can be split into a sequence of one or more dictionary words. Words may be reused.",
      "io_format": "Line 1: `s`. Line 2: the dictionary words (space-separated). Output: `true` or `false`.",
      "hints": [
        "Try every prefix that is a word and recurse on the rest. Without memoisation this is exponential (think of `aaaa...ab` with words `a`, `aa`, `aaa`).",
        "`dp[i]` is true when the first `i` characters can be segmented; `dp[0]` is true (empty prefix). For each `i`, look for a split point `j < i` with `dp[j]` true and `s[j..i)` in the dictionary. Only split points within the longest word length need checking."
      ],
      "going_deeper": "- A trie over the dictionary lets you extend all candidate words from a position in one walk.\n- Returning every segmentation (Word Break II) can produce exponentially many answers; memoise per start index.\n- Tokenisers for languages without spaces use the same DP with word probabilities (Viterbi).",
      "tests_count": 7,
      "example": {
        "input": "leetcode\nleet code\n",
        "expected": "true\n"
      },
      "path": "content/dsa/problems/word-break",
      "solutions": {
        "cpp": "content/dsa/problems/word-break/solution.cpp",
        "python": "content/dsa/problems/word-break/solution.py",
        "java": "content/dsa/problems/word-break/Solution.java"
      }
    }
  ],
  "sheets": [
    {
      "id": "blind-75",
      "title": "Blind 75",
      "total": 75,
      "path": "content/dsa/sheets/blind-75-neetcode-150/README.md",
      "standardized": 27,
      "problem_slugs": [
        "best-time-to-buy-and-sell-stock",
        "climbing-stairs",
        "coin-change",
        "container-with-most-water",
        "contains-duplicate",
        "course-schedule",
        "find-minimum-in-rotated-sorted-array",
        "group-anagrams",
        "house-robber",
        "invert-binary-tree",
        "longest-increasing-subsequence",
        "longest-palindromic-substring",
        "longest-substring-without-repeating-characters",
        "maximum-depth-of-binary-tree",
        "maximum-subarray",
        "merge-intervals",
        "merge-two-sorted-lists",
        "number-of-islands",
        "product-of-array-except-self",
        "reverse-linked-list",
        "search-in-rotated-sorted-array",
        "three-sum",
        "top-k-frequent-elements",
        "two-sum",
        "valid-anagram",
        "valid-parentheses",
        "word-break"
      ]
    },
    {
      "id": "neetcode-150",
      "title": "NeetCode 150",
      "total": 150,
      "path": "content/dsa/sheets/blind-75-neetcode-150/README.md",
      "standardized": 31,
      "problem_slugs": [
        "best-time-to-buy-and-sell-stock",
        "binary-search",
        "climbing-stairs",
        "coin-change",
        "container-with-most-water",
        "contains-duplicate",
        "course-schedule",
        "find-minimum-in-rotated-sorted-array",
        "group-anagrams",
        "house-robber",
        "invert-binary-tree",
        "longest-increasing-subsequence",
        "longest-palindromic-substring",
        "longest-substring-without-repeating-characters",
        "maximum-depth-of-binary-tree",
        "maximum-subarray",
        "median-of-two-sorted-arrays",
        "merge-intervals",
        "merge-two-sorted-lists",
        "number-of-islands",
        "product-of-array-except-self",
        "reverse-linked-list",
        "search-in-rotated-sorted-array",
        "sort-colors",
        "three-sum",
        "top-k-frequent-elements",
        "trapping-rain-water",
        "two-sum",
        "valid-anagram",
        "valid-parentheses",
        "word-break"
      ]
    },
    {
      "id": "striver-sde",
      "title": "Striver SDE Sheet",
      "total": null,
      "path": "content/dsa/sheets/striver-sde-sheet/README.md",
      "standardized": 17,
      "problem_slugs": [
        "best-time-to-buy-and-sell-stock",
        "longest-increasing-subsequence",
        "longest-substring-without-repeating-characters",
        "maximum-depth-of-binary-tree",
        "maximum-subarray",
        "median-of-two-sorted-arrays",
        "merge-intervals",
        "merge-two-sorted-lists",
        "number-of-islands",
        "reverse-linked-list",
        "search-in-rotated-sorted-array",
        "sort-colors",
        "three-sum",
        "trapping-rain-water",
        "two-sum",
        "valid-parentheses",
        "word-break"
      ]
    },
    {
      "id": "babbar-450",
      "title": "Love Babbar 450",
      "total": 450,
      "path": "content/dsa/sheets/love-babbar-450/README.md",
      "standardized": 16,
      "problem_slugs": [
        "best-time-to-buy-and-sell-stock",
        "coin-change",
        "invert-binary-tree",
        "longest-increasing-subsequence",
        "longest-palindromic-substring",
        "maximum-depth-of-binary-tree",
        "maximum-subarray",
        "median-of-two-sorted-arrays",
        "merge-intervals",
        "reverse-linked-list",
        "search-in-rotated-sorted-array",
        "sort-colors",
        "three-sum",
        "trapping-rain-water",
        "valid-parentheses",
        "word-break"
      ]
    }
  ],
  "patterns": [
    {
      "id": "array",
      "title": "array",
      "problem_slugs": [
        "best-time-to-buy-and-sell-stock",
        "binary-search",
        "container-with-most-water",
        "contains-duplicate",
        "find-minimum-in-rotated-sorted-array",
        "house-robber",
        "maximum-subarray",
        "median-of-two-sorted-arrays",
        "merge-intervals",
        "product-of-array-except-self",
        "search-in-rotated-sorted-array",
        "sort-colors",
        "three-sum",
        "top-k-frequent-elements",
        "trapping-rain-water",
        "two-sum"
      ]
    },
    {
      "id": "bfs",
      "title": "bfs",
      "problem_slugs": [
        "course-schedule",
        "maximum-depth-of-binary-tree",
        "number-of-islands"
      ]
    },
    {
      "id": "binary-search",
      "title": "binary search",
      "problem_slugs": [
        "binary-search",
        "find-minimum-in-rotated-sorted-array",
        "longest-increasing-subsequence",
        "median-of-two-sorted-arrays",
        "search-in-rotated-sorted-array"
      ]
    },
    {
      "id": "bucket-sort",
      "title": "bucket sort",
      "problem_slugs": [
        "top-k-frequent-elements"
      ]
    },
    {
      "id": "dfs",
      "title": "dfs",
      "problem_slugs": [
        "invert-binary-tree",
        "maximum-depth-of-binary-tree",
        "number-of-islands"
      ]
    },
    {
      "id": "divide-and-conquer",
      "title": "divide and conquer",
      "problem_slugs": [
        "median-of-two-sorted-arrays"
      ]
    },
    {
      "id": "dynamic-programming",
      "title": "dynamic programming",
      "problem_slugs": [
        "climbing-stairs",
        "coin-change",
        "house-robber",
        "longest-increasing-subsequence",
        "longest-palindromic-substring",
        "maximum-subarray",
        "word-break"
      ]
    },
    {
      "id": "graph",
      "title": "graph",
      "problem_slugs": [
        "course-schedule",
        "number-of-islands"
      ]
    },
    {
      "id": "greedy",
      "title": "greedy",
      "problem_slugs": [
        "best-time-to-buy-and-sell-stock",
        "container-with-most-water"
      ]
    },
    {
      "id": "hash-map",
      "title": "hash map",
      "problem_slugs": [
        "group-anagrams",
        "longest-substring-without-repeating-characters",
        "top-k-frequent-elements",
        "two-sum",
        "valid-anagram"
      ]
    },
    {
      "id": "hash-set",
      "title": "hash set",
      "problem_slugs": [
        "contains-duplicate",
        "word-break"
      ]
    },
    {
      "id": "heap",
      "title": "heap",
      "problem_slugs": [
        "top-k-frequent-elements"
      ]
    },
    {
      "id": "intervals",
      "title": "intervals",
      "problem_slugs": [
        "merge-intervals"
      ]
    },
    {
      "id": "linked-list",
      "title": "linked list",
      "problem_slugs": [
        "merge-two-sorted-lists",
        "reverse-linked-list"
      ]
    },
    {
      "id": "math",
      "title": "math",
      "problem_slugs": [
        "climbing-stairs"
      ]
    },
    {
      "id": "matrix",
      "title": "matrix",
      "problem_slugs": [
        "number-of-islands"
      ]
    },
    {
      "id": "prefix-sum",
      "title": "prefix sum",
      "problem_slugs": [
        "product-of-array-except-self"
      ]
    },
    {
      "id": "sliding-window",
      "title": "sliding window",
      "problem_slugs": [
        "longest-substring-without-repeating-characters"
      ]
    },
    {
      "id": "sorting",
      "title": "sorting",
      "problem_slugs": [
        "group-anagrams",
        "merge-intervals",
        "three-sum"
      ]
    },
    {
      "id": "stack",
      "title": "stack",
      "problem_slugs": [
        "trapping-rain-water",
        "valid-parentheses"
      ]
    },
    {
      "id": "string",
      "title": "string",
      "problem_slugs": [
        "group-anagrams",
        "longest-palindromic-substring",
        "longest-substring-without-repeating-characters",
        "valid-anagram",
        "valid-parentheses",
        "word-break"
      ]
    },
    {
      "id": "topological-sort",
      "title": "topological sort",
      "problem_slugs": [
        "course-schedule"
      ]
    },
    {
      "id": "tree",
      "title": "tree",
      "problem_slugs": [
        "invert-binary-tree",
        "maximum-depth-of-binary-tree"
      ]
    },
    {
      "id": "two-pointers",
      "title": "two pointers",
      "problem_slugs": [
        "container-with-most-water",
        "longest-palindromic-substring",
        "merge-two-sorted-lists",
        "sort-colors",
        "three-sum",
        "trapping-rain-water"
      ]
    }
  ],
  "companies": [],
  "companies_note": "No verified company tags exist in this repository, so none are exported. The field is reserved.",
  "cs_notes": [
    {
      "id": "operating-systems",
      "title": "Operating Systems",
      "path": "content/cs-fundamentals/operating-systems/README.md",
      "level": "intermediate",
      "top_questions": [
        "What is an operating system and what is the kernel?",
        "What is the difference between a program, a process and a thread?",
        "What states can a process be in, and what causes each transition?",
        "What is stored in a PCB and what happens during a context switch?",
        "What is the difference between user mode and kernel mode, and how does a system call work?",
        "What do fork and exec do, and what is copy-on-write?",
        "What are zombie and orphan processes?",
        "Compare FCFS, SJF, Round Robin and priority scheduling.",
        "How do you choose the time quantum for Round Robin?",
        "What is a race condition and what must a critical-section solution guarantee?",
        "What is the difference between a mutex and a semaphore?",
        "When would you use a spinlock instead of a mutex?",
        "How do you solve the producer-consumer problem?",
        "What are the necessary conditions for deadlock?",
        "Compare deadlock prevention, avoidance and detection.",
        "What is the difference between deadlock, livelock and starvation?",
        "Compare paging and segmentation. What kinds of fragmentation does each cause?",
        "What is virtual memory and what happens on a page fault?",
        "What is the TLB and why is it needed?",
        "Compare FIFO, LRU and Optimal page replacement. What is Belady's anomaly?",
        "What is thrashing and how do you deal with it?",
        "What is an inode, and how do hard links differ from symbolic links?",
        "Which IPC mechanism would you choose, and why is shared memory the fastest?",
        "What is the difference between user-level and kernel-level threads?",
        "What is priority inversion and how is it handled?"
      ],
      "diagrams": 6
    },
    {
      "id": "dbms-and-sql",
      "title": "DBMS and SQL",
      "path": "content/cs-fundamentals/dbms-and-sql/README.md",
      "level": "intermediate",
      "top_questions": [
        "What is a DBMS and why use one instead of files?",
        "Explain super key, candidate key, primary key and foreign key.",
        "What is the difference between DELETE, TRUNCATE and DROP?",
        "Explain the different types of joins.",
        "What is the difference between WHERE and HAVING?",
        "What is normalization? Explain 1NF, 2NF and 3NF.",
        "What is the difference between 3NF and BCNF?",
        "When would you denormalize?",
        "What are the ACID properties?",
        "How does a database implement atomicity and durability?",
        "What are dirty reads, non-repeatable reads and phantom reads?",
        "Explain the four SQL isolation levels.",
        "What is a lost update and how do you prevent it?",
        "What are shared and exclusive locks, and what is two-phase locking?",
        "What is MVCC and why is it used?",
        "How do databases handle deadlocks?",
        "What is an index and why do databases use B+ trees?",
        "What is the difference between a clustered and a non-clustered index?",
        "What are composite and covering indexes?",
        "Why not index every column, and when is an index not used?",
        "How would you investigate a slow query?",
        "How does the database execute a join?",
        "When would you choose NoSQL over a relational database?",
        "Explain the CAP theorem.",
        "What is the difference between replication and sharding, and how do you choose a shard key?"
      ],
      "diagrams": 6
    },
    {
      "id": "computer-networks",
      "title": "Computer Networks",
      "path": "content/cs-fundamentals/computer-networks/README.md",
      "level": "intermediate",
      "top_questions": [
        "What are the layers of the OSI model and what does each do?",
        "How does the TCP/IP model differ from the OSI model?",
        "What is the difference between TCP and UDP, and when would you use UDP?",
        "What is the difference between a MAC address and an IP address?",
        "What is DNS and how does a name get resolved?",
        "What happens when you type a URL into a browser and press Enter?",
        "Explain the TCP three-way handshake. Why three steps?",
        "How is a TCP connection closed, and what is TIME_WAIT?",
        "How does TCP provide reliable delivery?",
        "What is the difference between flow control and congestion control?",
        "Explain slow start, congestion avoidance and fast retransmit.",
        "What do idempotent and safe mean for HTTP methods?",
        "HTTP is stateless. How do websites keep you logged in?",
        "Compare HTTP/1.1, HTTP/2 and HTTP/3.",
        "How does HTTPS work?",
        "Why does TLS use both symmetric and asymmetric encryption?",
        "How many hosts fit in a /26 network, and what are its subnet mask and address range?",
        "What are private IP addresses and how does NAT work?",
        "What do ARP and DHCP do?",
        "What is the difference between a switch and a router, and how does a router choose where to send a packet?",
        "What is the difference between a layer 4 and a layer 7 load balancer?",
        "When would you use WebSockets instead of polling or Server-Sent Events?",
        "What is a CDN and how does it speed up a site?",
        "What is head-of-line blocking?",
        "A user reports that your service is unreachable or slow. How do you troubleshoot?"
      ],
      "diagrams": 7
    },
    {
      "id": "oops-and-concurrency",
      "title": "OOP and Concurrency",
      "path": "content/cs-fundamentals/oops-and-concurrency/README.md",
      "level": "intermediate",
      "top_questions": [
        "What is object-oriented programming, and what is the difference between a class and an object?",
        "Explain the four pillars of OOP.",
        "What is the difference between encapsulation and abstraction?",
        "What is the difference between method overloading and overriding?",
        "How does run-time polymorphism work?",
        "When would you use an abstract class and when an interface?",
        "Why does Java not support multiple inheritance of classes?",
        "Why is composition often preferred over inheritance?",
        "What is the contract between equals and hashCode?",
        "What is an immutable class and how do you create one?",
        "What are the SOLID principles?",
        "Give an example of a Liskov substitution violation.",
        "What is the difference between dependency inversion and dependency injection?",
        "How do you implement a thread-safe singleton, and what are the drawbacks of singletons?",
        "What is the difference between the Factory and Builder patterns?",
        "Explain the Strategy pattern with an example.",
        "Explain the Observer pattern and where it is used.",
        "How is the Decorator pattern different from inheritance?",
        "Describe the lifecycle of a thread.",
        "What is a race condition and how do you fix one?",
        "What is the difference between synchronized and ReentrantLock?",
        "What causes a deadlock and how do you prevent it?",
        "Why use a thread pool, and how do you choose its size?",
        "How would you implement the producer-consumer problem?",
        "What is the difference between optimistic and pessimistic locking?"
      ],
      "diagrams": 6
    }
  ],
  "system_design": [
    {
      "id": "lld-index",
      "track": "lld",
      "title": "Low-Level Design (LLD) & Machine Coding",
      "level": "intermediate",
      "path": "content/system-design/lld-machine-coding/README.md",
      "diagrams": 0
    },
    {
      "id": "elevator",
      "track": "lld",
      "title": "Elevator System",
      "level": "intermediate",
      "path": "content/system-design/lld-machine-coding/elevator/README.md",
      "diagrams": 2
    },
    {
      "id": "lru-cache",
      "track": "lld",
      "title": "LRU Cache",
      "level": "intermediate",
      "path": "content/system-design/lld-machine-coding/lru-cache/README.md",
      "diagrams": 2
    },
    {
      "id": "parking-lot",
      "track": "lld",
      "title": "Parking Lot",
      "level": "intermediate",
      "path": "content/system-design/lld-machine-coding/parking-lot/README.md",
      "diagrams": 2
    },
    {
      "id": "rate-limiter",
      "track": "lld",
      "title": "Rate Limiter",
      "level": "intermediate",
      "path": "content/system-design/lld-machine-coding/rate-limiter/README.md",
      "diagrams": 2
    },
    {
      "id": "splitwise",
      "track": "lld",
      "title": "Splitwise (Expense Sharing)",
      "level": "intermediate",
      "path": "content/system-design/lld-machine-coding/splitwise/README.md",
      "diagrams": 2
    },
    {
      "id": "hld-index",
      "track": "hld",
      "title": "High-Level Design (HLD) and Distributed Systems",
      "level": "experienced",
      "path": "content/system-design/hld-distributed-systems/README.md",
      "diagrams": 0
    },
    {
      "id": "case-studies--distributed-rate-limiter",
      "track": "hld",
      "title": "Case Study: Distributed Rate Limiter",
      "level": "experienced",
      "path": "content/system-design/hld-distributed-systems/case-studies/distributed-rate-limiter.md",
      "diagrams": 2
    },
    {
      "id": "case-studies--news-feed",
      "track": "hld",
      "title": "Case Study: News Feed",
      "level": "experienced",
      "path": "content/system-design/hld-distributed-systems/case-studies/news-feed.md",
      "diagrams": 2
    },
    {
      "id": "case-studies--notification-system",
      "track": "hld",
      "title": "Case Study: Notification System",
      "level": "experienced",
      "path": "content/system-design/hld-distributed-systems/case-studies/notification-system.md",
      "diagrams": 2
    },
    {
      "id": "case-studies--payment-ledger",
      "track": "hld",
      "title": "Case Study: Payment Ledger",
      "level": "experienced",
      "path": "content/system-design/hld-distributed-systems/case-studies/payment-ledger.md",
      "diagrams": 2
    },
    {
      "id": "case-studies--typeahead-autocomplete",
      "track": "hld",
      "title": "Case Study: Typeahead and Search Autocomplete",
      "level": "experienced",
      "path": "content/system-design/hld-distributed-systems/case-studies/typeahead-autocomplete.md",
      "diagrams": 2
    },
    {
      "id": "case-studies--uber-ride-hailing",
      "track": "hld",
      "title": "Case Study: Ride-Hailing System (like Uber)",
      "level": "experienced",
      "path": "content/system-design/hld-distributed-systems/case-studies/uber-ride-hailing.md",
      "diagrams": 2
    },
    {
      "id": "case-studies--url-shortener",
      "track": "hld",
      "title": "Case Study: URL Shortener",
      "level": "experienced",
      "path": "content/system-design/hld-distributed-systems/case-studies/url-shortener.md",
      "diagrams": 2
    },
    {
      "id": "case-studies--web-crawler",
      "track": "hld",
      "title": "Case Study: Web Crawler",
      "level": "experienced",
      "path": "content/system-design/hld-distributed-systems/case-studies/web-crawler.md",
      "diagrams": 2
    },
    {
      "id": "case-studies--whatsapp-messaging",
      "track": "hld",
      "title": "Case Study: Chat Messaging System (like WhatsApp)",
      "level": "experienced",
      "path": "content/system-design/hld-distributed-systems/case-studies/whatsapp-messaging.md",
      "diagrams": 2
    },
    {
      "id": "case-studies--youtube-video-streaming",
      "track": "hld",
      "title": "Case Study: Video Streaming Platform (like YouTube)",
      "level": "experienced",
      "path": "content/system-design/hld-distributed-systems/case-studies/youtube-video-streaming.md",
      "diagrams": 2
    },
    {
      "id": "trade-off-matrices",
      "track": "hld",
      "title": "Trade-off Matrices for High-Level Design",
      "level": "experienced",
      "path": "content/system-design/hld-distributed-systems/trade-off-matrices.md",
      "diagrams": 0
    },
    {
      "id": "ai-llm-index",
      "track": "ai-llm",
      "title": "AI / LLM System Design",
      "level": "experienced",
      "path": "content/system-design/ai-llm-system-design/README.md",
      "diagrams": 0
    },
    {
      "id": "agentic-sandboxes",
      "track": "ai-llm",
      "title": "Agentic Systems and Sandboxes",
      "level": "experienced",
      "path": "content/system-design/ai-llm-system-design/agentic-sandboxes.md",
      "diagrams": 2
    },
    {
      "id": "evals-and-guardrails",
      "track": "ai-llm",
      "title": "Evals and Guardrails",
      "level": "experienced",
      "path": "content/system-design/ai-llm-system-design/evals-and-guardrails.md",
      "diagrams": 2
    },
    {
      "id": "hybrid-search",
      "track": "ai-llm",
      "title": "Hybrid Search (Lexical + Dense Retrieval)",
      "level": "experienced",
      "path": "content/system-design/ai-llm-system-design/hybrid-search.md",
      "diagrams": 3
    },
    {
      "id": "llm-serving-and-inference",
      "track": "ai-llm",
      "title": "LLM Serving and Inference",
      "level": "experienced",
      "path": "content/system-design/ai-llm-system-design/llm-serving-and-inference.md",
      "diagrams": 2
    },
    {
      "id": "production-rag",
      "track": "ai-llm",
      "title": "Production RAG (Retrieval-Augmented Generation)",
      "level": "experienced",
      "path": "content/system-design/ai-llm-system-design/production-rag.md",
      "diagrams": 3
    }
  ],
  "sql_drills": [
    {
      "id": "01-filter-and-sort",
      "number": 1,
      "title": "filter and sort",
      "question": "Employees earning more than 100000, highest paid first (ties by name).",
      "level": "beginner",
      "reference_sql": "SELECT emp_name, salary\nFROM employees\nWHERE salary > 100000\nORDER BY salary DESC, emp_name;",
      "expected_rows": [
        [
          "Asha",
          "250000"
        ],
        [
          "Bilal",
          "180000"
        ],
        [
          "Chitra",
          "180000"
        ],
        [
          "Esha",
          "150000"
        ],
        [
          "Hari",
          "140000"
        ],
        [
          "Dev",
          "120000"
        ]
      ],
      "path": "content/cs-fundamentals/dbms-and-sql/sql/practice/queries/01-filter-and-sort.sql"
    },
    {
      "id": "02-inner-join",
      "number": 2,
      "title": "inner join",
      "question": "Each employee with their department name (employees without a department are dropped).",
      "level": "beginner",
      "reference_sql": "SELECT e.emp_name, d.dept_name\nFROM employees AS e\nJOIN departments AS d ON d.dept_id = e.dept_id\nORDER BY d.dept_name, e.emp_name;",
      "expected_rows": [
        [
          "Asha",
          "Engineering"
        ],
        [
          "Bilal",
          "Engineering"
        ],
        [
          "Chitra",
          "Engineering"
        ],
        [
          "Dev",
          "Engineering"
        ],
        [
          "Hari",
          "Finance"
        ],
        [
          "Indu",
          "Finance"
        ],
        [
          "Esha",
          "Sales"
        ],
        [
          "Farhan",
          "Sales"
        ],
        [
          "Gita",
          "Sales"
        ]
      ],
      "path": "content/cs-fundamentals/dbms-and-sql/sql/practice/queries/02-inner-join.sql"
    },
    {
      "id": "03-left-join-missing",
      "number": 3,
      "title": "left join missing",
      "question": "Departments that have no employees (anti-join with LEFT JOIN ... IS NULL).",
      "level": "beginner",
      "reference_sql": "SELECT d.dept_name\nFROM departments AS d\nLEFT JOIN employees AS e ON e.dept_id = d.dept_id\nWHERE e.emp_id IS NULL;",
      "expected_rows": [
        [
          "Research"
        ]
      ],
      "path": "content/cs-fundamentals/dbms-and-sql/sql/practice/queries/03-left-join-missing.sql"
    },
    {
      "id": "04-group-by-having",
      "number": 4,
      "title": "group by having",
      "question": "Headcount and average salary per department, only departments with at least 3 people.",
      "level": "beginner",
      "reference_sql": "SELECT d.dept_name, COUNT(*) AS headcount, CAST(ROUND(AVG(e.salary)) AS INTEGER) AS avg_salary\nFROM employees AS e\nJOIN departments AS d ON d.dept_id = e.dept_id\nGROUP BY d.dept_name\nHAVING COUNT(*) >= 3\nORDER BY d.dept_name;",
      "expected_rows": [
        [
          "Engineering",
          "4",
          "182500"
        ],
        [
          "Sales",
          "3",
          "111667"
        ]
      ],
      "path": "content/cs-fundamentals/dbms-and-sql/sql/practice/queries/04-group-by-having.sql"
    },
    {
      "id": "05-second-highest-salary",
      "number": 5,
      "title": "second highest salary",
      "question": "Second highest DISTINCT salary (classic interview question).",
      "level": "intermediate",
      "reference_sql": "SELECT MAX(salary) AS second_highest\nFROM employees\nWHERE salary < (SELECT MAX(salary) FROM employees);",
      "expected_rows": [
        [
          "180000"
        ]
      ],
      "path": "content/cs-fundamentals/dbms-and-sql/sql/practice/queries/05-second-highest-salary.sql"
    },
    {
      "id": "06-self-join-manager",
      "number": 6,
      "title": "self join manager",
      "question": "Employees who earn more than half of their manager's salary.",
      "level": "intermediate",
      "reference_sql": "SELECT e.emp_name AS employee, m.emp_name AS manager\nFROM employees AS e\nJOIN employees AS m ON m.emp_id = e.manager_id\nWHERE e.salary * 2 > m.salary\nORDER BY e.emp_name;",
      "expected_rows": [
        [
          "Bilal",
          "Asha"
        ],
        [
          "Chitra",
          "Asha"
        ],
        [
          "Dev",
          "Bilal"
        ],
        [
          "Esha",
          "Asha"
        ],
        [
          "Farhan",
          "Esha"
        ],
        [
          "Gita",
          "Esha"
        ],
        [
          "Hari",
          "Asha"
        ],
        [
          "Indu",
          "Hari"
        ]
      ],
      "path": "content/cs-fundamentals/dbms-and-sql/sql/practice/queries/06-self-join-manager.sql"
    },
    {
      "id": "07-correlated-subquery",
      "number": 7,
      "title": "correlated subquery",
      "question": "Employees paid above the average of their own department.",
      "level": "intermediate",
      "reference_sql": "SELECT e.emp_name, e.salary\nFROM employees AS e\nWHERE e.salary > (SELECT AVG(x.salary) FROM employees AS x WHERE x.dept_id = e.dept_id)\nORDER BY e.emp_name;",
      "expected_rows": [
        [
          "Asha",
          "250000"
        ],
        [
          "Esha",
          "150000"
        ],
        [
          "Hari",
          "140000"
        ]
      ],
      "path": "content/cs-fundamentals/dbms-and-sql/sql/practice/queries/07-correlated-subquery.sql"
    },
    {
      "id": "08-window-rank",
      "number": 8,
      "title": "window rank",
      "question": "Salary rank inside each department. DENSE_RANK gives tied salaries the same rank with no gaps.",
      "level": "experienced",
      "reference_sql": "SELECT d.dept_name, e.emp_name, e.salary,\n       DENSE_RANK() OVER (PARTITION BY e.dept_id ORDER BY e.salary DESC) AS salary_rank\nFROM employees AS e\nJOIN departments AS d ON d.dept_id = e.dept_id\nORDER BY d.dept_name, salary_rank, e.emp_name;",
      "expected_rows": [
        [
          "Engineering",
          "Asha",
          "250000",
          "1"
        ],
        [
          "Engineering",
          "Bilal",
          "180000",
          "2"
        ],
        [
          "Engineering",
          "Chitra",
          "180000",
          "2"
        ],
        [
          "Engineering",
          "Dev",
          "120000",
          "3"
        ],
        [
          "Finance",
          "Hari",
          "140000",
          "1"
        ],
        [
          "Finance",
          "Indu",
          "85000",
          "2"
        ],
        [
          "Sales",
          "Esha",
          "150000",
          "1"
        ],
        [
          "Sales",
          "Gita",
          "95000",
          "2"
        ],
        [
          "Sales",
          "Farhan",
          "90000",
          "3"
        ]
      ],
      "path": "content/cs-fundamentals/dbms-and-sql/sql/practice/queries/08-window-rank.sql"
    },
    {
      "id": "09-top-earner-per-dept",
      "number": 9,
      "title": "top earner per dept",
      "question": "Highest paid employee(s) per department using a CTE + window function (ties are all returned).",
      "level": "experienced",
      "reference_sql": "WITH ranked AS (\n    SELECT dept_id, emp_name, salary,\n           RANK() OVER (PARTITION BY dept_id ORDER BY salary DESC) AS rnk\n    FROM employees\n    WHERE dept_id IS NOT NULL\n)\nSELECT d.dept_name, r.emp_name, r.salary\nFROM ranked AS r\nJOIN departments AS d ON d.dept_id = r.dept_id\nWHERE r.rnk = 1\nORDER BY d.dept_name;",
      "expected_rows": [
        [
          "Engineering",
          "Asha",
          "250000"
        ],
        [
          "Finance",
          "Hari",
          "140000"
        ],
        [
          "Sales",
          "Esha",
          "150000"
        ]
      ],
      "path": "content/cs-fundamentals/dbms-and-sql/sql/practice/queries/09-top-earner-per-dept.sql"
    },
    {
      "id": "10-recursive-cte-hierarchy",
      "number": 10,
      "title": "recursive cte hierarchy",
      "question": "Reporting chain below Asha (emp_id 1) with the depth of each person.",
      "level": "experienced",
      "reference_sql": "WITH RECURSIVE chain (emp_id, emp_name, depth) AS (\n    SELECT emp_id, emp_name, 0 FROM employees WHERE emp_id = 1\n    UNION ALL\n    SELECT e.emp_id, e.emp_name, c.depth + 1\n    FROM employees AS e\n    JOIN chain AS c ON e.manager_id = c.emp_id\n)\nSELECT depth, emp_name FROM chain ORDER BY depth, emp_name;",
      "expected_rows": [
        [
          "0",
          "Asha"
        ],
        [
          "1",
          "Bilal"
        ],
        [
          "1",
          "Chitra"
        ],
        [
          "1",
          "Esha"
        ],
        [
          "1",
          "Hari"
        ],
        [
          "1",
          "Jatin"
        ],
        [
          "2",
          "Dev"
        ],
        [
          "2",
          "Farhan"
        ],
        [
          "2",
          "Gita"
        ],
        [
          "2",
          "Indu"
        ]
      ],
      "path": "content/cs-fundamentals/dbms-and-sql/sql/practice/queries/10-recursive-cte-hierarchy.sql"
    },
    {
      "id": "11-many-to-many-hours",
      "number": 11,
      "title": "many to many hours",
      "question": "Total hours booked per project, with the number of people on it.",
      "level": "intermediate",
      "reference_sql": "SELECT p.project_name, COUNT(a.emp_id) AS people, SUM(a.hours) AS total_hours\nFROM projects AS p\nJOIN assignments AS a ON a.project_id = p.project_id\nGROUP BY p.project_name\nORDER BY total_hours DESC;",
      "expected_rows": [
        [
          "Search Revamp",
          "3",
          "400"
        ],
        [
          "CRM Migration",
          "3",
          "310"
        ],
        [
          "Mobile App",
          "2",
          "210"
        ],
        [
          "Audit 2024",
          "1",
          "90"
        ]
      ],
      "path": "content/cs-fundamentals/dbms-and-sql/sql/practice/queries/11-many-to-many-hours.sql"
    },
    {
      "id": "12-running-total",
      "number": 12,
      "title": "running total",
      "question": "Running payroll total in order of hire date (window frame).",
      "level": "experienced",
      "reference_sql": "SELECT hire_date, emp_name, salary,\n       SUM(salary) OVER (ORDER BY hire_date ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS running_payroll\nFROM employees\nORDER BY hire_date;",
      "expected_rows": [
        [
          "2015-03-01",
          "Asha",
          "250000",
          "250000"
        ],
        [
          "2016-11-20",
          "Esha",
          "150000",
          "400000"
        ],
        [
          "2017-04-05",
          "Hari",
          "140000",
          "540000"
        ],
        [
          "2017-07-15",
          "Bilal",
          "180000",
          "720000"
        ],
        [
          "2018-01-10",
          "Chitra",
          "180000",
          "900000"
        ],
        [
          "2019-02-14",
          "Farhan",
          "90000",
          "990000"
        ],
        [
          "2020-06-01",
          "Dev",
          "120000",
          "1110000"
        ],
        [
          "2021-09-30",
          "Gita",
          "95000",
          "1205000"
        ],
        [
          "2022-01-17",
          "Indu",
          "85000",
          "1290000"
        ],
        [
          "2023-05-08",
          "Jatin",
          "70000",
          "1360000"
        ]
      ],
      "path": "content/cs-fundamentals/dbms-and-sql/sql/practice/queries/12-running-total.sql"
    },
    {
      "id": "13-exists-unassigned",
      "number": 13,
      "title": "exists unassigned",
      "question": "Employees who are not assigned to any project (NOT EXISTS is NULL-safe, unlike NOT IN).",
      "level": "intermediate",
      "reference_sql": "SELECT e.emp_name\nFROM employees AS e\nWHERE NOT EXISTS (SELECT 1 FROM assignments AS a WHERE a.emp_id = e.emp_id)\nORDER BY e.emp_name;",
      "expected_rows": [
        [
          "Asha"
        ],
        [
          "Hari"
        ],
        [
          "Jatin"
        ]
      ],
      "path": "content/cs-fundamentals/dbms-and-sql/sql/practice/queries/13-exists-unassigned.sql"
    },
    {
      "id": "14-case-salary-band",
      "number": 14,
      "title": "case salary band",
      "question": "Bucket employees into salary bands with CASE and count each band.",
      "level": "beginner",
      "reference_sql": "SELECT CASE\n           WHEN salary >= 180000 THEN 'A: 180k+'\n           WHEN salary >= 100000 THEN 'B: 100k-180k'\n           ELSE 'C: under 100k'\n       END AS band,\n       COUNT(*) AS employees\nFROM employees\nGROUP BY band\nORDER BY band;",
      "expected_rows": [
        [
          "A: 180k+",
          "3"
        ],
        [
          "B: 100k-180k",
          "3"
        ],
        [
          "C: under 100k",
          "4"
        ]
      ],
      "path": "content/cs-fundamentals/dbms-and-sql/sql/practice/queries/14-case-salary-band.sql"
    }
  ],
  "behavioral": [
    {
      "id": "README",
      "title": "Behavioral and Career",
      "path": "content/behavioral-and-career/README.md"
    },
    {
      "id": "amazon-leadership-principles",
      "title": "Amazon Leadership Principles",
      "path": "content/behavioral-and-career/amazon-leadership-principles.md"
    },
    {
      "id": "company-rubrics",
      "title": "Company Rubrics: Google and Meta",
      "path": "content/behavioral-and-career/company-rubrics.md"
    },
    {
      "id": "question-bank",
      "title": "Behavioral Question Bank",
      "path": "content/behavioral-and-career/question-bank.md"
    },
    {
      "id": "resume-ats-guide",
      "title": "Resume and ATS Guide",
      "path": "content/behavioral-and-career/resume-ats-guide.md"
    },
    {
      "id": "salary-negotiation-guide",
      "title": "Salary Negotiation Guide",
      "path": "content/behavioral-and-career/salary-negotiation-guide.md"
    },
    {
      "id": "star-and-carl-frameworks",
      "title": "STAR and CARL Frameworks",
      "path": "content/behavioral-and-career/star-and-carl-frameworks.md"
    }
  ]
}
