Arrays coding problems
Array problems are the first round of almost every coding interview and online assessment. Practise indexing, in-place updates, rotations and scans, then move on to prefix sums, two pointers and sliding windows built on top of them.
88 problems: 51 easy, 32 medium, 5 hard. Free to read; a free account solves them and earns XP and Aura.
- Count Consecutive OccurrencesPractice · +10 XP · dynamic programming, arrays, loopseasy
- Count Distinct ElementsPractice · +10 XP · sorting, counting, arrayseasy
- Count Elements Greater Than NeighborPractice · +10 XP · arrays, countingeasy
- Count Elements Greater Than PreviousPractice · +10 XP · greedy, arrays, loopseasy
- Count Elements Less Than KPractice · +10 XP · binary search, arrayseasy
- Count Equal NeighborsPractice · +10 XP · basics, arrays, loopseasy
- Count Even Numbers in WindowPractice · +10 XP · sliding window, arrayseasy
- Count Max Element in WindowPractice · +10 XP · sliding window, arrayseasy
- Count Non-Negative SubarraysPractice · +10 XP · sliding window, prefix sums, arrayseasy
- Count Numbers Divisible by KPractice · +10 XP · dynamic programming, arrays, basic programmingeasy
- Count occurrences of a numberPractice · +10 XP · basics, loops, arrayseasy
- Count Occurrences of a Target ValuePractice · +10 XP · arrays, loops, countingeasy
- Count Pairs with Specific SumPractice · +10 XP · sliding window, two pointers, arrayseasy
- Find Duplicate in Sorted ArrayPractice · +10 XP · two pointers, arrays, binary searcheasy
- Find Element After StepsPractice · +10 XP · linked structures, simulation, arrayseasy
- Find Element in Sorted ArrayPractice · +10 XP · binary search, arrayseasy
- Find End of Linked ListPractice · +10 XP · linked structures, simulation, arrayseasy
- Find First Even NumberPractice · +10 XP · two pointers, arrays, searchingeasy
- Find First OccurrencePractice · +10 XP · binary search, arrays, searchingeasy
- Find Linked List TailPractice · +10 XP · linked structures, arrays, traversaleasy
- Find Max Element in WindowPractice · +10 XP · sliding window, arrays, maximumeasy
- Find Minimum and MaximumPractice · +10 XP · arrays, min-maxeasy
- Find Node at Fixed DepthPractice · +10 XP · linked structures, simulation, arrayseasy
- Find Pair with SumPractice · +10 XP · two pointers, array, two sumeasy
- Find Root of TreePractice · +10 XP · trees, arrayseasy
- Find Second Largest ElementPractice · +10 XP · arrays, sorting, loopseasy
- Find Smallest Missing Positive IntegerPractice · +10 XP · two pointers, binary search, arrayseasy
- Find the First Negative NumberPractice · +10 XP · queue, simulation, arrayseasy
- Find the Single NumberPractice · +10 XP · bit manipulation, xor tricks, arrayseasy
- Last Element in RangePractice · +10 XP · stack, arrayseasy
- Leaf CountPractice · +10 XP · trees, arrayseasy
- Majority ElementDaily · +5 XP · +3 Aura (late, half) · arrays, counting2 solvedeasy
- Max Element in PrefixPractice · +10 XP · stack, prefix sums, arrayseasy
- Maximize Non-Negative SumPractice · +10 XP · greedy, arrayseasy
- Maximum Sum of a Fixed-Size SubarrayPractice · +10 XP · sliding window, arrays, prefix sumseasy
- Minimum Absolute DifferencePractice · +10 XP · greedy, sorting, arrayseasy
- Next ElementPractice · +10 XP · linked structures, arrays, simulationeasy
- Next Element in ArrayPractice · +10 XP · linked structures, simulation, arrayseasy
- Parent Array RootPractice · +10 XP · trees, arrayseasy
- Print Array in ReversePractice · +10 XP · basics, arrayseasy
- Print Numbers in Reverse OrderPractice · +10 XP · recursion, arrays, iterationeasy
- Reverse ArrayPractice · +10 XP · recursion, arrays, backtrackingeasy
- Smallest ElementPractice · +10 XP · greedy, arrays, iterationeasy
- Stack Push CounterPractice · +10 XP · stack, simulation, arrayseasy
- Sum of Adjacent ElementsPractice · +10 XP · two pointers, arrays, loopseasy
- Sum of Array ElementsPractice · +10 XP · recursion, arrays, iterationeasy
- Sum of Elements in WindowPractice · +10 XP · sliding window, arrayseasy
- Sum of Next ValuesPractice · +10 XP · linked structures, arrays, simulationeasy
- The Lucky DipOpen now · Daily · +10 XP · +5 Aura · arrays, max, simple loopeasy
- Tree Depth SumPractice · +10 XP · trees, arrays, summationeasy
- Two Pointers SumPractice · +10 XP · two pointers, arrays, two sumeasy
- Array Prefix Maxima and MinimaPractice · +20 XP · arrays, prefix sums, running max/minmedium
- Consecutive DuplicatesPractice · +20 XP · arrays, counting, run-length encodingmedium
- Count Elements with Equal NeighborsPractice · +20 XP · hash map, counting, arraysmedium
- Count Matching PairsPractice · +20 XP · hash map, counting, arraysmedium
- Count Pairs with Equal Digit GCDPractice · +20 XP · math, number theory, arraysmedium
- Count Pairs with Equal Digit SumPractice · +20 XP · math, hashing, arraysmedium
- Count Pairs with Equal ProductPractice · +20 XP · arrays, hash map, countingmedium
- Count Pairs with Sum Divisible by KPractice · +20 XP · arrays, hashing, number theorymedium
- Distinct Consecutive PairsPractice · +20 XP · arrays, hash map, countingmedium
- Distinct Elements in a Sliding WindowPractice · +20 XP · arrays, hash map, sliding windowmedium
- Distinct Elements in PrefixPractice · +20 XP · arrays, hash set, prefix sumsmedium
- Find Closest Smaller ElementPractice · +20 XP · stack, monotonic stack, arraymedium
- Find Duplicate Node in PathPractice · +20 XP · linked structures, arrays, cyclesmedium
- Find the First Unique ElementPractice · +20 XP · hash map, arrays, frequencymedium
- Group by ValuePractice · +20 XP · hash map, grouping, arraysmedium
- Indices of Next Smaller ElementPractice · +20 XP · stack, monotonic stack, arraymedium
- Longest Sorted SubsegmentPractice · +20 XP · two pointers, arrays, sliding windowmedium
- Longest Subarray with At Most K Duplicate PairsPractice · +20 XP · sliding window, hash map, arraysmedium
- Longest Subarray with Constant DifferencePractice · +20 XP · two pointers, greedy, arraysmedium
- Max Difference Between Two Prefix SumsPractice · +20 XP · prefix sums, range queries, arraysmedium
- Maximum Average SubsegmentPractice · +20 XP · binary search, prefix sums, arraysmedium
- Maximum Prefix Sum DifferencePractice · +20 XP · prefix sums, array, maximummedium
- Maximum Sum of Consecutive SubsegmentsPractice · +20 XP · dynamic programming, array, greedymedium
- Maximum Sum of Non-Adjacent Elements in a Circular ArrayPractice · +20 XP · dynamic programming, greedy, arraysmedium
- Maximum Sum of Non-Adjacent SubarraysPractice · +20 XP · dynamic programming, arrays, greedymedium
- Minimum Operations to Make Array SortedPractice · +20 XP · greedy, sorting, arraysmedium
- Next Greater Element on RightPractice · +20 XP · stack, monotonic stack, arraysmedium
- Stack Maximum DifferencePractice · +20 XP · stack, monotonic stack, arraymedium
- Subarray Digit SumsPractice · +20 XP · math, prefix sums, arraysmedium
- Subarray with Target ProductPractice · +20 XP · arrays, hash map, prefix productmedium
- Sum of Distinct ElementsPractice · +20 XP · recursion, hashing, arraysmedium
- Sum of Next Greater Element PairsPractice · +20 XP · stack, array, monotonic stackmedium
- Largest Rectangle in a HistogramPractice · +30 XP · monotonic stack, arrayshard
- Longest Balanced SubarrayPractice · +30 XP · arrays, hash maps, prefix sumshard
- Maximum Sum of Non-Adjacent ElementsPractice · +30 XP · basics, dynamic programming, arrayshard
- Maximum Sum Subarray with Length ConstraintPractice · +30 XP · dynamic programming, arrays, optimizationhard
- Subarray Minimums with SumPractice · +30 XP · arrays, monotonic stack, prefix sumshard
Solve these free. Get paid in XP and Aura.
One tap with Google, no card. Every first accepted solve pays XP for the leaderboards and Aura for real goodies.
Other topics
Hash Map and Hashing101Prefix Sums64SQL and Databases64Beginner Coding Problems60Graphs, BFS and DFS45Greedy41Sliding Window39Dynamic Programming37Sorting36Math and Number Theory36Strings35Two Pointers35Stack29Binary Search25Simulation25Recursion22Linked List20Trees20Heap and Priority Queue18Matrix and Grid18Bit Manipulation18Queue and Deque16