Post

Classic Problems

Non-Overlapping Segments

Number of Sets of K Non-Overlapping Line Segments

Reverse Pairs

Examples:

Solutions:

  • Merge Sort
  • Fenwick Tree
  • Segment Tree
  • Binary Search Tree

Swim in Rising Water

Solutions:

  • Dijkstra’s Algorithm
  • BinarySearch + BFS/DFS
  • Union-Find
1

Subarray Sum Equals K

Count Number of Nice Subarrays

  • Sliding window
  • If we apply nums[i] -> nums[i] % 2, the problem becomes Subarray Sum Equals K, and we can use hash map to store the count of each sum during iteration.
This post is licensed under CC BY 4.0 by the author.