DSABeginnerReady

Linear Patterns Assessment

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

Question 1multiple-choiceBeginner

8 pts

Two-pointer applicability and invariant reasoning

When is a two-pointer solution a defensible choice instead of a brute-force nested loop?

Question 2codingBeginner

14 pts

Implementing opposite-direction two pointers

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.

Question 3code-reviewBeginner

14 pts

Code review of two-pointer string scanning

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.

Question 4scenarioIntermediate

14 pts

Sliding window in production systems

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.

Question 5codingIntermediate

14 pts

Variable-size sliding window with frequency map

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.

Question 6codingBeginner

12 pts

Prefix sum preprocessing and query trade-offs

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.

Question 7codingIntermediate

14 pts

Prefix sum with hash map for non-monotonic arrays

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.

Question 8scenarioIntermediate

10 pts

Difference array for offline range updates

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?