Skip to main contentCode.Socratic
Sign inStart free

Socratic interview practice

You may know coding, but can you talk about it?

Interviews are a conversation, not a submit button. Code.Socratic reads the code you wrote and asks you to explain it.

Sessions need a wider screen.

A session is a code editor, the tutor and a test runner, side by side. Together they need about a laptop’s width.

Sign up now and your free problem will be waiting.

A session, with the problem solved

Approach, complexity, then code. The tutor asks for the plan before the syntax and keeps asking after the tests pass.

Python

Widest Water Between Posts

Medium
credits 46
solution.py
def solve(heights):
    left, right = 0, len(heights) - 1
    best = 0

    while left < right:
        width = right - left
        best = max(best, width * min(heights[left], heights[right]))

        # The shorter post caps this pair, and every pair still to come
        # behind it is narrower, so it can never beat what we have.
        if heights[left] <= heights[right]:
            left += 1
        else:
            right -= 1

    return best
hints 011:38
You
Two pointers, one at each end. Each step I move the shorter post inward.
AI tutor
Why the shorter one? Say what you throw away when you move it.
You
Every pair that used that post. The width only shrinks from here, and that post already caps the height.
AI tutor
Good. So the loop is O(n), one pass, no extra space. Agreed. Write it.
You
Done. Both samples and all seven hidden tests pass.
AI tutor
They do. Harder question, and it is the one an interviewer asks next: what happens on the step where the two posts are exactly equal, and why is it safe to move either?
  • Hidden tests run server-side
  • Difficulty-weighted score
  • Your code carried through the session

Not another problem grinder

Coding was never single-player

Every turn goes both ways: you explain, it pushes back, you answer. Nothing here is graded by a submit button.

You
Two pointers, one at each end. Each step I move the shorter post inward.
AI tutor
Why the shorter one? Say what you throw away when you move it.
You
Every pair that used that post. The width only shrinks from here, and that post already caps the height.

It remembers your code, then asks why

The tutor carries your actual solution through the session, so the question is never generic. It asks about the line you wrote, and why.

You don’t have to be a coder yet

Ask what a line does and it will walk you through it. Learn how working code works, and why, before you can write it.

while left < right:
AI tutor
Two markers, one at each end, walking toward each other. The loop runs until they meet.

That question up there is yours to answer. The next question is yours to answer.

One problem, free, no card. Talk through it and find out what you sound like before someone else is listening.