lc-sensei

All walkthroughs

Every walkthrough Sensei has built: the reasoning, a playable trace, simple Python, and what to say out loud. New here? Start with the install guide.

LC 1 · EASY

Two Sum

One pass, complements in a map: check before you insert.

LC 2 · MEDIUM

Add Two Numbers

Add one column at a time and let a single carry bit remember everything.

LC 5 · MEDIUM

Longest Palindromic Substring

Every palindrome has a center — expand from each one and keep the widest mirror.

LC 11 · MEDIUM

Container With Most Water

Move the shorter wall: only it can unlock a taller future.

LC 22 · MEDIUM

Generate Parentheses

Open while opens remain, close only while closes trail opens — every answer is one root-to-leaf path.

LC 41 · HARD

First Missing Positive

Put each useful value in its home slot, then read the first gap.

LC 46 · MEDIUM

Permutations

Fix one slot at a time; every unused number gets a turn, then un-choose.

LC 84 · HARD

Largest Rectangle in Histogram

A bar's height ends where a shorter bar begins.

LC 239 · HARD

Sliding Window Maximum

Keep only future champions: discard what's smaller, evict what's stale, read the front.

LC 332 · HARD

Reconstruct Itinerary

Fly the smallest ticket first, fix airports post-order, read the route backwards.

LC 560 · MEDIUM

Subarray Sum Equals K

A matching earlier prefix is one valid start; count its frequency before inserting the current sum.

LC 787 · MEDIUM

Cheapest Flights Within K Stops

K stops means K+1 edges: relax level by level.

LC 2333 · MEDIUM

Minimum Sum of Squared Difference

Pool k1+k2 into one budget and spend every move on the current largest gap.