Complete Array Problems & Resources Guide
Hey everyone! Arrays are the foundation of data structures and algorithms. Every tech interview and competitive programming contest features array problems. I've spent years mastering array techniques, and I want to share a complete roadmap that will take you from basics to advanced patterns.
The key insight: Arrays aren't just about storing data sequentially. They're the building block for understanding space-time tradeoffs, prefix sums, sliding windows, two pointers, and countless optimization techniques. Master arrays, and you've mastered the foundation of algorithmic thinking.
Understanding Arrays
What makes Arrays fundamental? Arrays are the most basic data structure, but the techniques built on top of them (two pointers, sliding window, prefix sums, Kadane's algorithm) are powerful problem-solving paradigms used everywhere in software engineering and competitive programming.
For Tech Interviews: You need to master core patterns: two pointers, sliding window, prefix sums, matrix traversal, and array manipulation. About 80-100 well-understood problems is ideal. Most interview problems are easy to medium difficulty, with a few hard problems testing optimization skills.
For Competitive Programming: You need deep understanding of advanced techniques like contribution to sum, range queries, coordinate compression, and combining arrays with other data structures. This requires 150-200+ problems and familiarity with mathematical insights.
Best Learning Resources
Video Resources for Interview Prep
NeetCode - Arrays & Hashing - The gold standard for learning array interview patterns. Clear explanations with Python implementations. Covers all essential techniques systematically.
take U forward (Striver) - Arrays Series - Extremely comprehensive with detailed explanations. 40+ hours covering basics through advanced patterns. Best for building deep understanding.
Back To Back SWE - Array Problems - Excellent breakdown of thought process and optimization techniques. Great for understanding how to approach unfamiliar problems.
Kevin Naughton Jr. - Array & String Playlist - Clear solutions to common interview problems. Good for quick reference and practice.
Abdul Bari - Arrays - Best for understanding the fundamental theory, time complexity analysis, and space tradeoffs.
Video Resources for Competitive Programming
Errichto - Arrays & Prefix Sums - Advanced array techniques for CP. Covers contribution to answer, prefix sums variations, and problem-solving strategies.
SecondThread - Array Techniques - Shows how to combine arrays with other techniques. Great for advanced optimization patterns.
William Fiset - Data Structures - Clear explanations of advanced array-based structures like Fenwick trees and segment trees.
Colin Galen - Problem Solving - Real contest problem walkthroughs showing array technique applications.
Written Resources
For Interviews:
- LeetCode Arrays 101 Explore Card
- Tech Interview Handbook - Arrays
- GeeksforGeeks Arrays
- InterviewBit - Arrays Problems
For Competitive Programming:
- Codeforces Array Techniques
- CP-Algorithms - Various Array Topics
- USACO Guide - General Arrays
- USACO Guide - Prefix Sums
- Codeforces Educational Resources
Books Worth Reading
Cracking the Coding Interview - Excellent array problems with detailed solutions and patterns.
Elements of Programming Interviews - Great array problems with focus on optimization techniques.
Competitive Programming 4 - Comprehensive coverage of array techniques with CP applications.
Programming Pearls - Classic book with elegant array problem solutions and insights.
Algorithm Design Manual - Strong focus on array manipulation and problem-solving strategies.
Interview Problems (100 Total)
Phase 1: Array Basics & Traversal (15 problems)
Master fundamental operations. If you struggle here, everything else will be harder.
- Running Sum of 1d Array
- Shuffle the Array
- Kids With the Greatest Number of Candies
- Number of Good Pairs
- How Many Numbers Are Smaller Than the Current Number
- Create Target Array in the Given Order
- Decompress Run-Length Encoded List
- Find Numbers with Even Number of Digits
- Squares of a Sorted Array
- Sort Array By Parity
- Remove Duplicates from Sorted Array
- Remove Element
- Move Zeroes
- Plus One
- Third Maximum Number
Phase 2: Two Pointers Technique (15 problems)
Essential pattern for optimization. Reduces O(n²) to O(n) in many cases.
- Two Sum II - Input Array Is Sorted
- Reverse String
- Valid Palindrome
- Container With Most Water
- 3Sum
- 4Sum
- Sort Colors
- Merge Sorted Array
- Remove Duplicates from Sorted Array II
- Partition Labels
- Boats to Save People
- Minimize Maximum Pair Sum in Array
- Trapping Rain Water
- Next Permutation
- Rotate Array
Phase 3: Sliding Window (15 problems)
The most important optimization pattern. Essential for substring/subarray problems.
- Maximum Average Subarray I
- Find All Anagrams in a String
- Permutation in String
- Longest Substring Without Repeating Characters
- Longest Repeating Character Replacement
- Minimum Window Substring
- Sliding Window Maximum
- Minimum Size Subarray Sum
- Fruit Into Baskets
- Max Consecutive Ones III
- Grumpy Bookstore Owner
- Frequency of the Most Frequent Element
- Longest Substring with At Most K Distinct Characters
- Subarrays with K Different Integers
- Count Number of Nice Subarrays
Phase 4: Prefix Sums & Hash Maps (15 problems)
Powerful technique for range queries and subarray problems.
- Two Sum
- Subarray Sum Equals K
- Continuous Subarray Sum
- Contiguous Array
- Product of Array Except Self
- Find Pivot Index
- Range Sum Query - Immutable
- Range Sum Query 2D - Immutable
- Minimum Operations to Reduce X to Zero
- Maximum Sum of Distinct Subarrays With Length K
- Subarray Sums Divisible by K
- Make Sum Divisible by P
- Count Nice Pairs in an Array
- Find the Longest Substring Containing Vowels in Even Counts
- Maximum Points You Can Obtain from Cards
Phase 5: Matrix & 2D Arrays (10 problems)
Essential for understanding multi-dimensional array manipulation.
- Spiral Matrix
- Spiral Matrix II
- Rotate Image
- Set Matrix Zeroes
- Diagonal Traverse
- Valid Sudoku
- Game of Life
- Word Search
- Number of Islands
- Pacific Atlantic Water Flow
Phase 6: Kadane's Algorithm & Variants (10 problems)
Maximum subarray problems - classic DP pattern that's crucial to master.
- Maximum Subarray
- Maximum Product Subarray
- Best Time to Buy and Sell Stock
- Best Time to Buy and Sell Stock II
- Best Time to Buy and Sell Stock III
- Best Time to Buy and Sell Stock IV
- Maximum Sum Circular Subarray
- Longest Turbulent Subarray
- Maximum Length of Subarray With Positive Product
- Flip String to Monotone Increasing
Phase 7: Advanced Array Techniques (10 problems)
Combining multiple patterns and advanced optimization.
- Longest Consecutive Sequence
- First Missing Positive
- Find All Duplicates in an Array
- Find All Numbers Disappeared in an Array
- Jump Game
- Jump Game II
- Gas Station
- Candy
- Task Scheduler
- Insert Interval
Phase 8: Sorting & Searching Variations (10 problems)
Array problems requiring sorting or custom search patterns.
- Merge Intervals
- Non-overlapping Intervals
- Meeting Rooms II
- Top K Frequent Elements
- Kth Largest Element in an Array
- Find K Pairs with Smallest Sums
- Largest Number
- H-Index
- Count of Range Sum
- Maximum Gap
Competitive Programming Problems
AtCoder Array Problems (20 problems)
- ABC 086 C - Traveling
- ABC 122 C - GeT AC
- ABC 125 C - GCD on Blackboard
- ABC 129 C - Typical Stairs
- ABC 166 D - I hate Factorization
- ABC 179 D - Leaping Tak
- ABC 182 D - Wandering
- ABC 188 D - Snuke Prime
- ABC 207 C - Many Segments
- ABC 221 D - Online games
- ABC 233 D - Count Interval
- ABC 241 D - Sequence Query
- ABC 247 D - Cylinder
- ABC 281 D - Max Multiple
- ABC 295 D - Three Days Ago
- ARC 098 C - Attention
- ABC 304 D - A Piece of Cake
- ABC 315 D - Magical Cookies
- ABC 322 D - Polyomino
- ARC 073 D - Simple Knapsack
CSES Array Problems (12 problems)
- Distinct Numbers
- Apartments
- Ferris Wheel
- Concert Tickets
- Restaurant Customers
- Movie Festival
- Sum of Two Values
- Maximum Subarray Sum
- Stick Lengths
- Playlist
- Towers
- Traffic Lights
Codeforces Array Problems by Rating
Rating 800-1000 (Beginner):
- Round 479 Div3 - A - Wrong Subtraction
- Round 486 Div3 - A - Diverse Team
- Round 501 Div3 - A - Points in Segments
- Round 535 Div3 - A - Two Distinct Points
- Round 661 Div3 - A - Remove Smallest
Rating 1000-1200 (Easy):
- Round 367 Div2 - B - Interesting drink
- Round 479 Div3 - C - Less or Equal
- Round 486 Div3 - C - Equal Sums
- Round 580 Div2 - B - Make Product Equal One
- Round 693 Div3 - C - Long Jumps
Rating 1200-1400 (Medium):
- Round 344 Div2 - C - Report
- Round 380 Div2 - C - Road to Cinema
- Round 479 Div3 - D - Divide by three, multiply by two
- Round 535 Div3 - C - Edgy Trees
- Round 661 Div3 - D - Maximum Distributed Tree
Rating 1400-1600 (Advanced):
- Round 290 Div2 - C - Fox And Names
- Round 363 Div2 - C - Vacations
- Round 394 Div2 - C - Dasha and Password
- Round 427 Div2 - C - Star sky
- Round 486 Div3 - D - Points and Powers of Two
Rating 1600-1800 (Expert):
- Round 256 Div2 - C - Painting Fence
- Round 283 Div2 - C - Removing Columns
- Round 325 Div2 - C - Gennady the Dentist
- Round 340 Div2 - D - Something with XOR Queries
- Round 392 Div2 - C - Planar Reflections
Rating 1800-2000 (Candidate Master):
- Round 243 Div2 - D - Sereja and Squares
- Round 268 Div2 - D - Two Sets
- Round 285 Div2 - C - Misha and Forest
- Round 321 Div2 - C - Kefa and Park
- Round 348 Div2 - C - Little Artem and Random Variable
Advanced CP Topics
Difference Arrays & Range Updates:
- CF - Greg and Array
- CF - Little Girl and Maximum XOR
- SPOJ - UPDATEIT
- CF - Pashmak and Parmida's problem
- AtCoder - Increment of Matrix
2D Prefix Sums:
- CSES - Forest Queries
- CF - Greg and Graph
- AtCoder - Flip Cells
- CF - Beautiful Sequence
- SPOJ - MATSUM
Contribution to Sum:
- CF - Number of Subsequences
- CF - Pashmak and Buses
- AtCoder - Intervals on Tree
- CF - Square Subsets
- CF - Divisibility
Sliding Window Maximum:
- SPOJ - ARRAYSUB
- CF - Maximum White Subtree
- AtCoder - Subsequence Sum
- CF - Xenia and Tree
- CSES - Sliding Window Median
Coordinate Compression:
- CF - Sereja and Brackets
- AtCoder - Static Range Sum
- CF - Pashmak and Graph
- SPOJ - KQUERY
- CF -Vasya and Beautiful Arrays
Learning Timeline
For Interview Preparation (5-6 weeks)
Week 1: Array Fundamentals Solve all 15 problems from Phase 1. Master basic operations: traversal, insertion, deletion, searching. Understand time/space complexity of array operations. Practice explaining your code clearly.
Week 2: Two Pointers Mastery Complete all 15 problems from Phase 2. This is a critical pattern that appears constantly. Learn to recognize when two pointers can reduce O(n²) to O(n). Practice both same-direction and opposite-direction pointer techniques.
Week 3: Sliding Window Pattern Solve all 15 problems from Phase 3. THE most important optimization technique for substring/subarray problems. Master fixed-size and variable-size windows. Understand the expand/shrink pattern.
Week 4: Prefix Sums & Hash Maps Complete Phase 4 (15 problems). Learn to transform problems using prefix sums. Master the hash map + prefix sum combination for O(n) subarray solutions. This pattern is extremely powerful.
Week 5: Matrices & Kadane's Algorithm Solve Phase 5 (10 problems) and Phase 6 (10 problems). Learn 2D array manipulation and the maximum subarray pattern. These are classic interview topics.
Week 6: Advanced Patterns & Review Complete Phase 7 and Phase 8. Practice mixed problems. Do mock interviews. Time yourself. Review weak areas. Focus on explaining your thought process clearly.
For Competitive Programming (4-5 months)
Month 1: Solid Foundation Complete all CSES array problems. Solve AtCoder problems 1-15. Practice Codeforces 800-1200 rated problems. Master prefix sums, difference arrays, and two pointers. Target 50-60 problems.
Month 2: Intermediate Techniques Complete remaining AtCoder problems. Solve Codeforces 1200-1500 rated problems. Learn 2D prefix sums, coordinate compression, and sliding window maximum. Target 40-50 problems.
Month 3: Advanced Patterns Master contribution to sum techniques. Learn to combine arrays with segment trees and fenwick trees. Practice 1500-1700 rated problems. Target 35-45 problems.
Month 4: Expert Level Study advanced range query techniques. Master sparse tables and square root decomposition. Solve 1700-1900 rated problems. Target 30-40 problems.
Month 5: Mastery & Speed Participate in virtual contests. Practice recognizing patterns quickly. Focus on implementation speed and bug-free code. Solve 1900+ rated problems. Target 25-30 problems.
Final Thoughts
Arrays are the foundation of algorithmic problem solving. Mastering array techniques is essential for both interviews and competitive programming.
For interviews, focus on the five main patterns: two pointers, sliding window, prefix sums, Kadane's algorithm, and hash maps. Solve 80-100 problems across all patterns and you'll be well-prepared. The key is recognizing which pattern applies and implementing it bug-free.
For competitive programming, you need to combine basic patterns with advanced techniques like segment trees, coordinate compression, and contribution to sum. Practice formulating solutions that optimize both time and space.
Remember: Arrays may seem simple, but the techniques built on them are the foundation of almost every advanced algorithm. Master arrays, and you've mastered the foundation.