8 pts
Two-pointer applicability and invariant reasoning
When is a two-pointer solution a defensible choice instead of a brute-force nested loop?
This assessment verifies the Linear Patterns module. Passing it contributes up to 8 points in the 15-22 score band.
Questions
8
Limit
75m
Pass
85%
Score
+8
8 pts
When is a two-pointer solution a defensible choice instead of a brute-force nested loop?
14 pts
Given a sorted integer array and a target, return the indexes of two numbers whose sum equals the target. If no pair exists, return an empty result. Explain the invariant, edge cases, and complexity.
14 pts
A candidate solves valid palindrome by repeatedly creating substrings, reversing them, and comparing after every character cleanup. Review the risk and propose the production-grade core algorithm for user-entered text.
14 pts
Design the core logic for a per-user API rate limiter: allow at most 100 requests in any rolling 60-second window. Explain the data structure, window movement, memory trade-off, and failure edge cases.
14 pts
Return the length of the longest substring with at most k distinct characters. Include why the window shrink step is correct and what happens when k is zero.
12 pts
A dashboard repeatedly asks for total revenue between day l and day r over a stable daily revenue array. Design the preprocessing and query formula. State the update limitation.
14 pts
Count the number of subarrays whose sum equals k. The array may contain negative numbers. Explain why a simple sliding window is not safe and give the stronger approach.
10 pts
A promotion engine receives 200,000 offline range updates of the form add x credits to every user index from l to r, then needs the final credit array once. Which pattern should you use, and what limitation must you communicate?