AI writes the code.
You're judged on everything else.
Practice the part AI can't do for you: understanding the problem, choosing the approach, and knowing whether it's the best one.
Your first AI round is free.
Rain falls on a row of unit-wide walls. Return the water the row holds.
Example 1
Input: height = [3, 0, 2, 0, 4]
Output: 7
Solution.javaYou're typing
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
int trap(int[] height) {
int lo = 0, hi = height.length - 1, level = 0, water = 0;
// the lower end is settled, so it is the one that moves in
while (lo < hi) {
int low = Math.min(height[lo], height[hi]);
level = Math.max(level, low);
water += level - low;
if (height[lo] < height[hi]) lo++; else hi--;
}
return water;
}
When the clock stops, your round is scored.
Whether your solution works, whether it's the best one, how well you used the AI agent, and what it cost.
int trap(int[] height) {
int lo = 0, hi = height.length - 1, level = 0, water = 0;
while (lo < hi) {
int low = Math.min(height[lo], height[hi]);
level = Math.max(level, low);
water += level - low;
if (height[lo] < height[hi]) lo++; else hi--;
}
return water;
}
AI agent, 6 messages
- Running hidden tests69 of 69 pass
- Comparing with the best approachMatches it
- Reviewing how you used the agent6 messages
- Adding up the agent's cost27,400 tokens
Final solution
Optimal
O(n) time, O(1) space
One pass from both ends, nothing stored. Every bar must be read, so O(n) is the floor.
AI efficiency
82 / 100
Short, specific questions. You wrote the code and used the agent to check your thinking.
Cost per task
$0.004
Messages6 of 20
Tokens27,400
69 of 69hidden tests pass
21:40of 30:00 used
Harddifficulty
Up next: Best Time to Buy and Sell Stock Another walk over a row.
AI roundPick up where the video ends.
Practice by pattern, revise before you forget, and keep one-page notes for everything else. One account, and your progress follows you to any device.
Two pointers
2 of 9 solved, in suggested order
MediumHard
| Problem | Difficulty | Companies | Video | ||
|---|---|---|---|---|---|
| Container With Most Water | Medium | 56 | |||
| 3Sum | Medium | 56 | |||
| Trapping Rain Water AI round | Hard | 72 | AI round | ||
| Find the Duplicate Number | Medium | 22 | |||
| Sort Colors | Medium | 37 | |||
| Remove Nth Node From End of List | Medium | 18 | |||
| Next Permutation | Medium | 32 |
Learn the thinking, then practice it.
Free videos walk through how a problem is solved, step by step. Then you solve it here, at your own pace or on the clock.
Start with one round.
Your first AI round is free.