Basic Two Pointers Problems for Coding Interviews
18 basic Two Pointers problems from real coding interviews, each with test cases you can run online. By difficulty they split into 18 basic, 0 intermediate and 0 advanced. The companies that ask them most often are Google, Meta, Microsoft, Amazon.
Solve a few problems of each level, name the pattern after each one and revisit the ones that needed a hint a week later. Practise stating the time and space complexity and the edge cases before you code.
Coding problems
- Valid Palindrome (Basic)
- Longest Palindrome From Letters (Basic)
- Minimum Adjacent Swaps for Palindrome (Basic)
- Maximum Weight Cut (Basic)
- Palindrome Linked List (Basic)
- Valid Palindrome With One Deletion (Basic)
- Prefix Sums of a Linked List (Basic)
- Reverse Second Half of a Linked List (Basic)
- Palindrome Permutation Check (Basic)
- Sort Vowels in a String (Basic)
- Build Array From Permutation (Basic)
- Count Palindromic Times in Interval (Basic)
- Minimum Changes to Make Palindrome (Basic)
- Palindrome Array Cost (Basic)
- Palindromic Clock Times in a Range (Basic)
- Palindromic Words Count (Basic)
- Palindromic Rows Count (Basic)
- Palindrome in a Given Base (Basic)
Related
Frequently asked questions
How do I get good at two pointers problems?
Practise by level, name the pattern after you solve each problem and review the ones you needed hints for. The list is ordered so you can start with the basic ones.
Can I run two pointers problems online here?
Yes. Each problem opens in an editor that runs your code against test cases in Java, Python, C++, Go, JavaScript and more.