24 problems · Rust Pattern Lab · 0 memorization

Stop memorizing.
Start reasoning.

Learn the pattern, state the invariant, break it with a counterexample, and verify the result. OpenGrind is DSA practice for an AI era where producing code is cheap and judging it is essential.

New · Rust-first

Pattern Lab starts before the solution.

Decode the constraints, state the invariant, take one nudge if needed, then reveal the trace and Rust implementation. Your review queue stays on this device.

Open the Pattern Lab →

The durable skill is not typing the answer.

You solve one, peek at the answer, close the tab, and forget it by Friday. AI can make that loop even faster without making it deeper. The fix is to recognize the structure, explain why it works, test where it fails, and retrieve it later in a different setting.

Three tracks. One habit.

Each track is a couple of templates up top, then variations that reuse them.

Binary Search

Sorted input and a "find the boundary" question? Three templates cover every variant — exact match, leftmost, and search-on-answer. Learn where the pointers land and stop guessing at `<` vs `<=`.

7 problems
Open Binary Search →
# template A — closed interval
lo, hi = 0, len(nums) - 1
while lo <= hi:
    mid = (lo + hi) // 2
    if nums[mid] == target:
        return mid
    elif nums[mid] < target:
        lo = mid + 1
    else:
        hi = mid - 1

Linked Lists

Pointer choreography without the segfaults. Reverse in place, find the cycle with fast/slow, merge two sorted lists. Once you see the moves, the "hard" ones are just the easy ones stacked.

11 problems
Open Linked Lists →
# reverse in place
prev = None
while head:
    nxt = head.next
    head.next = prev
    prev = head
    head = nxt
return prev

Sliding Window

Two pointers, one window. Grow it to include, shrink it to stay valid, track the best as you go. Fixed-size or variable — every window problem is the same loop with a different invariant.

6 problems
Open Sliding Window →
# variable window
left = 0
for right in range(len(s)):
    add(s[right])
    while invalid():
        remove(s[left])
        left += 1
    best = max(best, right - left + 1)

Patterns, not problems.

The tell that fires before you've read the whole prompt.

Two PointersSorted array, pair or windowSearch on Answer"Minimize the max…" phrasingFast & SlowCycle, middle, nth-from-endVariable WindowLongest/shortest substring

See it move.

Watch the search space halve, one probe at a time.

◧ live · Template AWatch the interval halve. lo and hi bracket the live range; mid is probed each step.target =

Start anywhere.

A pin for every problem. Grab one and go.

EasyLC 704

Binary Search

Binary Search

Sorted array, distinct-ish values, "find the index of target" or "does target exist". The most l…

O(log n)
MediumLC 74

Search a 2D Matrix

Binary Search

A matrix where each row is sorted AND the first value of each row exceeds the last of the previo…

O(log(m·n))
MediumLC 875

Koko Eating Bananas

Binary Search

No sorted array in sight — instead: "find the minimum speed / smallest capacity / least X such t…

O(n · log(max pile))
MediumLC 153

Find Minimum in Rotated Sorted Array

Binary Search

A sorted array that has been rotated at an unknown pivot, and you need the minimum (i.e. the rot…

O(log n)
EasyLC 206

Reverse Linked List

Linked Lists

A singly linked list, and you need to reverse the direction of all pointers. The signal: "revers…

O(n)
EasyLC 21

Merge Two Sorted Lists

Linked Lists

Two sorted linked lists, merge them into one sorted list. The signal: "merge two sorted", "combi…

O(n + m)
EasyLC 141

Linked List Cycle

Linked Lists

A linked list that might have a cycle (a node pointing back to an earlier node, creating an infi…

O(n)
HardLC 23

Merge K Sorted Lists

Linked Lists

Given k sorted linked lists, merge them into one sorted list. The signal: "merge k lists", "comb…

O(n log k)
EasyLC 121

Best Time to Buy and Sell Stock

Sliding Window

An array of stock prices. You can buy once and sell once (buy must come before sell). Find the m…

O(n)
MediumLC 3

Longest Substring Without Repeating Characters

Sliding Window

Find the longest substring with no duplicate characters. Signal: "longest substring", "no repeat…

O(n)
MediumLC 424

Longest Repeating Character Replacement

Sliding Window

You can perform at most k character replacements. Find the longest substring with repeating char…

O(n)
MediumLC 567

Permutation In String

Sliding Window

Check if a permutation of s1 exists as a substring in s2. Signal: "permutation", "substring", or…

O(n)