This repository has been archived on 2022-06-22. You can view files and clone it, but cannot push or open issues or pull requests.
usaco-guide/content/4_Silver/5_Silver_2P.md
Benjamin Qi 6e9f121024 minor
2020-06-09 12:57:44 -04:00

41 lines
No EOL
1.5 KiB
Markdown

---
slug: /silver/two-pointers
title: "Two Pointers"
author: Darren Yao
order: 5
prerequisites:
-
- Silver - Sorting
---
**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.
<!-- END DESCRIPTION -->
## Tutorials
- Intro to USACO 14.1
- CPH 8.1
## Problems
- CSES
- [Sum of Two Values](https://cses.fi/problemset/task/1640)
- USACO
- [Silver - Diamond Collector](http://usaco.org/index.php?page=viewproblem2&cpid=643)
- sort and then use 2P
- [Silver - Paired Up](http://usaco.org/index.php?page=viewproblem2&cpid=738)
- sort and then use 2P
- [Gold - Haybale Feast](http://usaco.org/index.php?page=viewproblem2&cpid=767)
- just 2P with additional set
- CF
- [Books](https://codeforces.com/problemset/problem/279/B)
- [Cellular Network](http://codeforces.com/problemset/problem/702/C) [](48)
- [USB vs. PS/2](http://codeforces.com/problemset/problem/762/B) [](53)
- [K-Good Segment](http://codeforces.com/problemset/problem/616/D) [](53)
- [(Long Title)](http://codeforces.com/problemset/problem/814/C) [](54)
- [Jury Meeting](http://codeforces.com/problemset/problem/853/B) [](90)
## 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](http://usaco.org/index.php?page=viewproblem2&cpid=600).