Sliding Window coding problems

Sliding window problems ask for the best subarray or substring under a rule: longest without repeats, fixed-size maximum sum, at most k distinct. Learn when the window grows, when it shrinks and what you keep inside it.

39 problems: 9 easy, 26 medium, 4 hard. Free to read; a free account solves them and earns XP and Aura.

  1. Count Elements Less Than K in WindowPractice · +10 XPeasy
  2. Count Even Numbers in WindowPractice · +10 XPeasy
  3. Count Max Element in WindowPractice · +10 XPeasy
  4. Count Non-Negative SubarraysPractice · +10 XPeasy
  5. Count Pairs with Specific SumPractice · +10 XPeasy
  6. Count Subarrays with Target SumPractice · +10 XPeasy
  7. Find Max Element in WindowPractice · +10 XPeasy
  8. Maximum Sum of a Fixed-Size SubarrayPractice · +10 XPeasy
  9. Sum of Elements in WindowPractice · +10 XPeasy
  10. Count Subarrays with Distinct ElementsPractice · +20 XPmedium
  11. Distinct Elements in a Sliding WindowPractice · +20 XPmedium
  12. Distinct Elements in Sliding WindowPractice · +20 XPmedium
  13. Find Minimums in Sliding WindowsPractice · +20 XPmedium
  14. Largest Element in PrefixPractice · +20 XPmedium
  15. Longest Alternating SubstringPractice · +20 XPmedium
  16. Longest Prefix With Maximum FrequencyPractice · +20 XPmedium
  17. Longest Prefix With No RepeatsPractice · +20 XPmedium
  18. Longest Segment with At Most K Distinct ElementsPractice · +20 XPmedium
  19. Longest Sorted SubsegmentPractice · +20 XPmedium
  20. Longest Subarray with Alternating ParityPractice · +20 XPmedium
  21. Longest Subarray with At Most K Distinct ElementsPractice · +20 XPmedium
  22. Longest Subarray with At Most K Duplicate PairsPractice · +20 XPmedium
  23. Longest Subarray with Bounded DifferencePractice · +20 XPmedium
  24. Longest Subarray with Equal HalvesPractice · +20 XPmedium
  25. Longest Subarray with Increasing SumPractice · +20 XPmedium
  26. Longest Subarray with Limited DifferencePractice · +20 XPmedium
  27. Longest Subarray with Sum at Most KPractice · +20 XPmedium
  28. Longest Subarray With Sum XPractice · +20 XPmedium
  29. Longest Substring With At Most K Distinct CharactersPractice · +20 XPmedium
  30. Longest Substring Without RepeatsPractice · +20 XPmedium
  31. Maximum Subarray Sum with Fixed LengthPractice · +20 XPmedium
  32. Optimal Training ScheduleOpen now · Weekly · +40 XP · +15 Auramedium
  33. Sliding Window MinimumPractice · +20 XPmedium
  34. String with Most Unique CharactersPractice · +20 XPmedium
  35. Sum of Two Adjacent ElementsPractice · +20 XPmedium
  36. Longest Subarray with Distinct ElementsPractice · +30 XPhard
  37. Minimize Maximum Difference of Elements in IntervalsPractice · +30 XPhard
  38. Minimum Cost Subarray with Sum at Least KPractice · +30 XPhard
  39. Minimum Window SubstringPractice · +30 XPhard