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.

  1. Count Consecutive OccurrencesPractice · +10 XPeasy
  2. Count Distinct ElementsPractice · +10 XPeasy
  3. Count Elements Greater Than NeighborPractice · +10 XPeasy
  4. Count Elements Greater Than PreviousPractice · +10 XPeasy
  5. Count Elements Less Than KPractice · +10 XPeasy
  6. Count Equal NeighborsPractice · +10 XPeasy
  7. Count Even Numbers in WindowPractice · +10 XPeasy
  8. Count Max Element in WindowPractice · +10 XPeasy
  9. Count Non-Negative SubarraysPractice · +10 XPeasy
  10. Count Numbers Divisible by KPractice · +10 XPeasy
  11. Count occurrences of a numberPractice · +10 XPeasy
  12. Count Occurrences of a Target ValuePractice · +10 XPeasy
  13. Count Pairs with Specific SumPractice · +10 XPeasy
  14. Find Duplicate in Sorted ArrayPractice · +10 XPeasy
  15. Find Element After StepsPractice · +10 XPeasy
  16. Find Element in Sorted ArrayPractice · +10 XPeasy
  17. Find End of Linked ListPractice · +10 XPeasy
  18. Find First Even NumberPractice · +10 XPeasy
  19. Find First OccurrencePractice · +10 XPeasy
  20. Find Linked List TailPractice · +10 XPeasy
  21. Find Max Element in WindowPractice · +10 XPeasy
  22. Find Minimum and MaximumPractice · +10 XPeasy
  23. Find Node at Fixed DepthPractice · +10 XPeasy
  24. Find Pair with SumPractice · +10 XPeasy
  25. Find Root of TreePractice · +10 XPeasy
  26. Find Second Largest ElementPractice · +10 XPeasy
  27. Find Smallest Missing Positive IntegerPractice · +10 XPeasy
  28. Find the First Negative NumberPractice · +10 XPeasy
  29. Find the Single NumberPractice · +10 XPeasy
  30. Last Element in RangePractice · +10 XPeasy
  31. Leaf CountPractice · +10 XPeasy
  32. Majority ElementDaily · +5 XP · +3 Aura (late, half)easy
  33. Max Element in PrefixPractice · +10 XPeasy
  34. Maximize Non-Negative SumPractice · +10 XPeasy
  35. Maximum Sum of a Fixed-Size SubarrayPractice · +10 XPeasy
  36. Minimum Absolute DifferencePractice · +10 XPeasy
  37. Next ElementPractice · +10 XPeasy
  38. Next Element in ArrayPractice · +10 XPeasy
  39. Parent Array RootPractice · +10 XPeasy
  40. Print Array in ReversePractice · +10 XPeasy
  41. Print Numbers in Reverse OrderPractice · +10 XPeasy
  42. Reverse ArrayPractice · +10 XPeasy
  43. Smallest ElementPractice · +10 XPeasy
  44. Stack Push CounterPractice · +10 XPeasy
  45. Sum of Adjacent ElementsPractice · +10 XPeasy
  46. Sum of Array ElementsPractice · +10 XPeasy
  47. Sum of Elements in WindowPractice · +10 XPeasy
  48. Sum of Next ValuesPractice · +10 XPeasy
  49. The Lucky DipOpen now · Daily · +10 XP · +5 Auraeasy
  50. Tree Depth SumPractice · +10 XPeasy
  51. Two Pointers SumPractice · +10 XPeasy
  52. Array Prefix Maxima and MinimaPractice · +20 XPmedium
  53. Consecutive DuplicatesPractice · +20 XPmedium
  54. Count Elements with Equal NeighborsPractice · +20 XPmedium
  55. Count Matching PairsPractice · +20 XPmedium
  56. Count Pairs with Equal Digit GCDPractice · +20 XPmedium
  57. Count Pairs with Equal Digit SumPractice · +20 XPmedium
  58. Count Pairs with Equal ProductPractice · +20 XPmedium
  59. Count Pairs with Sum Divisible by KPractice · +20 XPmedium
  60. Distinct Consecutive PairsPractice · +20 XPmedium
  61. Distinct Elements in a Sliding WindowPractice · +20 XPmedium
  62. Distinct Elements in PrefixPractice · +20 XPmedium
  63. Find Closest Smaller ElementPractice · +20 XPmedium
  64. Find Duplicate Node in PathPractice · +20 XPmedium
  65. Find the First Unique ElementPractice · +20 XPmedium
  66. Group by ValuePractice · +20 XPmedium
  67. Indices of Next Smaller ElementPractice · +20 XPmedium
  68. Longest Sorted SubsegmentPractice · +20 XPmedium
  69. Longest Subarray with At Most K Duplicate PairsPractice · +20 XPmedium
  70. Longest Subarray with Constant DifferencePractice · +20 XPmedium
  71. Max Difference Between Two Prefix SumsPractice · +20 XPmedium
  72. Maximum Average SubsegmentPractice · +20 XPmedium
  73. Maximum Prefix Sum DifferencePractice · +20 XPmedium
  74. Maximum Sum of Consecutive SubsegmentsPractice · +20 XPmedium
  75. Maximum Sum of Non-Adjacent Elements in a Circular ArrayPractice · +20 XPmedium
  76. Maximum Sum of Non-Adjacent SubarraysPractice · +20 XPmedium
  77. Minimum Operations to Make Array SortedPractice · +20 XPmedium
  78. Next Greater Element on RightPractice · +20 XPmedium
  79. Stack Maximum DifferencePractice · +20 XPmedium
  80. Subarray Digit SumsPractice · +20 XPmedium
  81. Subarray with Target ProductPractice · +20 XPmedium
  82. Sum of Distinct ElementsPractice · +20 XPmedium
  83. Sum of Next Greater Element PairsPractice · +20 XPmedium
  84. Largest Rectangle in a HistogramPractice · +30 XPhard
  85. Longest Balanced SubarrayPractice · +30 XPhard
  86. Maximum Sum of Non-Adjacent ElementsPractice · +30 XPhard
  87. Maximum Sum Subarray with Length ConstraintPractice · +30 XPhard
  88. Subarray Minimums with SumPractice · +30 XPhard