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/2P.md
2020-06-22 13:51:12 -07:00

36 lines
No EOL
1.4 KiB
Markdown

---
id: 2P
title: "Two Pointers"
author: Darren Yao
prerequisites:
- Silver - Introduction to Sorting
description: Two pointers refers to iterating two monotonic pointers across an array to search for a pair of indices satisfying some condition in linear time.
---
## 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).