<aside>
This section is part of the 5-hour LeetCode DSA Patterns course by Mukul Raina
Arrays are the most common data structure in coding interviews. Nearly every problem starts with an array or string as input. The difference between a brute force O(n²) solution and an optimal O(n) solution almost always comes down to one skill: knowing when to trade space for time by using a hash map or a prefix sum.
This section teaches you three foundational patterns that eliminate redundant work. Hash sets eliminate redundant searches. Hash maps eliminate redundant counting. Prefix sums eliminate redundant range calculations. Once you internalize these three tools, a large portion of "medium" array problems become straightforward.
What We'll Cover:
Where This Appears in Interviews:
| Company Type | How This Section Appears |
|---|---|
| FAANG / Big Tech | Two Sum variants, subarray sum problems, and frequency counting appear in nearly every phone screen |
| Mid-size companies | Array manipulation and hash map usage are the most common first-round questions |
| Startups | Practical data processing questions that reduce to hash maps or prefix sums |
| Online assessments | Timed problems where O(n) vs O(n²) determines pass/fail on large test cases |
Core Idea for This Section: When repeated lookup is the bottleneck, use hashing. When repeated range calculation is the bottleneck, use prefix sums. Both patterns trade O(n) space to eliminate an entire nested loop.
<aside>
Mukul Raina | youtube.com/@mukulraina | slides.mukulraina.com | LinkedIn
</aside>
<aside>
Mukul Raina | youtube.com/@mukulraina | slides.mukulraina.com | LinkedIn
</aside>