DSA, but personal

Don't justsolve.Understand.

Accepted is where most tools stop. LeafCode reads the approach you actually reached for, measures it against the one the problem rewards, and turns the distance between them into something you can watch happen.

Learn by watching the algorithm think, step by step.

Interactive algorithm visualizer

Two pointers · from both ends

Find a pair summing to 18

  1. 10
  2. 41
  3. 62
  4. 93
  5. 124
  6. 165
  7. 206
  1. lo ← 0; hi ← n−1
  2. while lo < hi:
  3. if condition(a[lo], a[hi]) is met:
  4. record the answer
  5. move whichever end cannot improve the answer
  6. return best recorded

Step 1 / 5 21 overshoots. 20 is the largest value left, so nothing can pair with it.

Time
O(n)
Space
O(1)

Each step discards one end for good, so no value is examined twice.

Your first working solution is a starting point, not a score.

A judge answers one question: did it pass? LeafCode asks the one that changes how you solve the next problem. How did you get there?

01 — 06

Submit

A push to your repository, or an attempt you paste in yourself.

POST /api/submissions

slug
two-sum-ii
language
cpp
status
accepted
source
github · commit 4e1f9c2

201 · { public_token: "9f3c…", status: "queued" }

Two Sum · sorted input

Same answer. A different amount of thinking.

Both of these are correct, and LeafCode says so. Watch one submission go through: written, classified, costed, and the gap it points at.

you.pseudoBrute force · nested loops
    Time
    O(n²)
    Space
    O(1)
    Rank
    4
    better.pseudo
      Time
      O(n)
      Space
      O(1)
      Rank
      2
      you.plotcomparisons against n
      n
        better.plotcomparisons against n
        n

          Four commitments, not four features.

          1. It never hands you the answer

            No table of working solutions exists. Lessons are pseudo code and prose, and a linter enforces that on every commit.

          2. It learns from your own code

            Not a curriculum you were assigned. The lesson exists because of something you submitted.

          3. Visualizations are deterministic

            A trace is data, generated ahead of time. The same steps, in the same order, every time you watch.

          4. Not knowing is a normal answer

            When LeafCode cannot tell what approach you used, it says so plainly instead of guessing at one.

          Stop collecting solutions.
          Start collecting ideas.