1.4 KiB
1.4 KiB
id | title | author | prerequisites | ||
---|---|---|---|---|---|
2P | Two Pointers | Darren Yao |
|
Two pointers refers to iterating two monotonic pointers across an array to search for a pair of indices satisfying some condition in O(n)
time.
Tutorials
- Intro to USACO 14.1
- CPH 8.1
Problems
- CSES
- USACO
- Silver - Diamond Collector
- sort and then use 2P
- Silver - Paired Up
- sort and then use 2P
- Gold - Haybale Feast
- just 2P with additional set
- Silver - Diamond Collector
- CF
Extensions
The two pointers technique can be extended to the two dimensional sliding window algorithm. If you're looking for a more challenging problem using 2-D sliding window, see USACO Plat Fort Moo.