PM Loading…
Description
Examples
Sample tests from the PatternMastery grader. Constraints and the full statement are on LeetCode.
Understanding the Problem
Signals that point to the pattern
Brute Force Approach
Building Intuition
The reusable pattern
Common Mistakes
Optimal Solution
Video walk-through
No video for this problem yet.
Other accepted approaches
Try it yourself: Python runs in your browser
Console
Click Run (or press Cmd/Ctrl+Enter). The first run downloads the Python runtime (~10 MB; cached).
How confident are you?
What We’ve Learned
Test Your Understanding
Community
Stuck or want to compare approaches? Join the Discord.
Ask the tutor
Be Socratic; ask for hints, not the full answer.