Skip to main content

Complete Array Problems & Resources Guide

· 18 min read

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:

For Competitive Programming:

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.

  1. Running Sum of 1d Array
  2. Shuffle the Array
  3. Kids With the Greatest Number of Candies
  4. Number of Good Pairs
  5. How Many Numbers Are Smaller Than the Current Number
  6. Create Target Array in the Given Order
  7. Decompress Run-Length Encoded List
  8. Find Numbers with Even Number of Digits
  9. Squares of a Sorted Array
  10. Sort Array By Parity
  11. Remove Duplicates from Sorted Array
  12. Remove Element
  13. Move Zeroes
  14. Plus One
  15. Third Maximum Number

Phase 2: Two Pointers Technique (15 problems)

Essential pattern for optimization. Reduces O(n²) to O(n) in many cases.

  1. Two Sum II - Input Array Is Sorted
  2. Reverse String
  3. Valid Palindrome
  4. Container With Most Water
  5. 3Sum
  6. 4Sum
  7. Sort Colors
  8. Merge Sorted Array
  9. Remove Duplicates from Sorted Array II
  10. Partition Labels
  11. Boats to Save People
  12. Minimize Maximum Pair Sum in Array
  13. Trapping Rain Water
  14. Next Permutation
  15. Rotate Array

Phase 3: Sliding Window (15 problems)

The most important optimization pattern. Essential for substring/subarray problems.

  1. Maximum Average Subarray I
  2. Find All Anagrams in a String
  3. Permutation in String
  4. Longest Substring Without Repeating Characters
  5. Longest Repeating Character Replacement
  6. Minimum Window Substring
  7. Sliding Window Maximum
  8. Minimum Size Subarray Sum
  9. Fruit Into Baskets
  10. Max Consecutive Ones III
  11. Grumpy Bookstore Owner
  12. Frequency of the Most Frequent Element
  13. Longest Substring with At Most K Distinct Characters
  14. Subarrays with K Different Integers
  15. Count Number of Nice Subarrays

Phase 4: Prefix Sums & Hash Maps (15 problems)

Powerful technique for range queries and subarray problems.

  1. Two Sum
  2. Subarray Sum Equals K
  3. Continuous Subarray Sum
  4. Contiguous Array
  5. Product of Array Except Self
  6. Find Pivot Index
  7. Range Sum Query - Immutable
  8. Range Sum Query 2D - Immutable
  9. Minimum Operations to Reduce X to Zero
  10. Maximum Sum of Distinct Subarrays With Length K
  11. Subarray Sums Divisible by K
  12. Make Sum Divisible by P
  13. Count Nice Pairs in an Array
  14. Find the Longest Substring Containing Vowels in Even Counts
  15. Maximum Points You Can Obtain from Cards

Phase 5: Matrix & 2D Arrays (10 problems)

Essential for understanding multi-dimensional array manipulation.

  1. Spiral Matrix
  2. Spiral Matrix II
  3. Rotate Image
  4. Set Matrix Zeroes
  5. Diagonal Traverse
  6. Valid Sudoku
  7. Game of Life
  8. Word Search
  9. Number of Islands
  10. Pacific Atlantic Water Flow

Phase 6: Kadane's Algorithm & Variants (10 problems)

Maximum subarray problems - classic DP pattern that's crucial to master.

  1. Maximum Subarray
  2. Maximum Product Subarray
  3. Best Time to Buy and Sell Stock
  4. Best Time to Buy and Sell Stock II
  5. Best Time to Buy and Sell Stock III
  6. Best Time to Buy and Sell Stock IV
  7. Maximum Sum Circular Subarray
  8. Longest Turbulent Subarray
  9. Maximum Length of Subarray With Positive Product
  10. Flip String to Monotone Increasing

Phase 7: Advanced Array Techniques (10 problems)

Combining multiple patterns and advanced optimization.

  1. Longest Consecutive Sequence
  2. First Missing Positive
  3. Find All Duplicates in an Array
  4. Find All Numbers Disappeared in an Array
  5. Jump Game
  6. Jump Game II
  7. Gas Station
  8. Candy
  9. Task Scheduler
  10. Insert Interval

Phase 8: Sorting & Searching Variations (10 problems)

Array problems requiring sorting or custom search patterns.

  1. Merge Intervals
  2. Non-overlapping Intervals
  3. Meeting Rooms II
  4. Top K Frequent Elements
  5. Kth Largest Element in an Array
  6. Find K Pairs with Smallest Sums
  7. Largest Number
  8. H-Index
  9. Count of Range Sum
  10. Maximum Gap

Competitive Programming Problems

AtCoder Array Problems (20 problems)

  1. ABC 086 C - Traveling
  2. ABC 122 C - GeT AC
  3. ABC 125 C - GCD on Blackboard
  4. ABC 129 C - Typical Stairs
  5. ABC 166 D - I hate Factorization
  6. ABC 179 D - Leaping Tak
  7. ABC 182 D - Wandering
  8. ABC 188 D - Snuke Prime
  9. ABC 207 C - Many Segments
  10. ABC 221 D - Online games
  11. ABC 233 D - Count Interval
  12. ABC 241 D - Sequence Query
  13. ABC 247 D - Cylinder
  14. ABC 281 D - Max Multiple
  15. ABC 295 D - Three Days Ago
  16. ARC 098 C - Attention
  17. ABC 304 D - A Piece of Cake
  18. ABC 315 D - Magical Cookies
  19. ABC 322 D - Polyomino
  20. ARC 073 D - Simple Knapsack

CSES Array Problems (12 problems)

  1. Distinct Numbers
  2. Apartments
  3. Ferris Wheel
  4. Concert Tickets
  5. Restaurant Customers
  6. Movie Festival
  7. Sum of Two Values
  8. Maximum Subarray Sum
  9. Stick Lengths
  10. Playlist
  11. Towers
  12. Traffic Lights

Codeforces Array Problems by Rating

Rating 800-1000 (Beginner):

  1. Round 479 Div3 - A - Wrong Subtraction
  2. Round 486 Div3 - A - Diverse Team
  3. Round 501 Div3 - A - Points in Segments
  4. Round 535 Div3 - A - Two Distinct Points
  5. Round 661 Div3 - A - Remove Smallest

Rating 1000-1200 (Easy):

  1. Round 367 Div2 - B - Interesting drink
  2. Round 479 Div3 - C - Less or Equal
  3. Round 486 Div3 - C - Equal Sums
  4. Round 580 Div2 - B - Make Product Equal One
  5. Round 693 Div3 - C - Long Jumps

Rating 1200-1400 (Medium):

  1. Round 344 Div2 - C - Report
  2. Round 380 Div2 - C - Road to Cinema
  3. Round 479 Div3 - D - Divide by three, multiply by two
  4. Round 535 Div3 - C - Edgy Trees
  5. Round 661 Div3 - D - Maximum Distributed Tree

Rating 1400-1600 (Advanced):

  1. Round 290 Div2 - C - Fox And Names
  2. Round 363 Div2 - C - Vacations
  3. Round 394 Div2 - C - Dasha and Password
  4. Round 427 Div2 - C - Star sky
  5. Round 486 Div3 - D - Points and Powers of Two

Rating 1600-1800 (Expert):

  1. Round 256 Div2 - C - Painting Fence
  2. Round 283 Div2 - C - Removing Columns
  3. Round 325 Div2 - C - Gennady the Dentist
  4. Round 340 Div2 - D - Something with XOR Queries
  5. Round 392 Div2 - C - Planar Reflections

Rating 1800-2000 (Candidate Master):

  1. Round 243 Div2 - D - Sereja and Squares
  2. Round 268 Div2 - D - Two Sets
  3. Round 285 Div2 - C - Misha and Forest
  4. Round 321 Div2 - C - Kefa and Park
  5. Round 348 Div2 - C - Little Artem and Random Variable

Advanced CP Topics

Difference Arrays & Range Updates:

  1. CF - Greg and Array
  2. CF - Little Girl and Maximum XOR
  3. SPOJ - UPDATEIT
  4. CF - Pashmak and Parmida's problem
  5. AtCoder - Increment of Matrix

2D Prefix Sums:

  1. CSES - Forest Queries
  2. CF - Greg and Graph
  3. AtCoder - Flip Cells
  4. CF - Beautiful Sequence
  5. SPOJ - MATSUM

Contribution to Sum:

  1. CF - Number of Subsequences
  2. CF - Pashmak and Buses
  3. AtCoder - Intervals on Tree
  4. CF - Square Subsets
  5. CF - Divisibility

Sliding Window Maximum:

  1. SPOJ - ARRAYSUB
  2. CF - Maximum White Subtree
  3. AtCoder - Subsequence Sum
  4. CF - Xenia and Tree
  5. CSES - Sliding Window Median

Coordinate Compression:

  1. CF - Sereja and Brackets
  2. AtCoder - Static Range Sum
  3. CF - Pashmak and Graph
  4. SPOJ - KQUERY
  5. 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.