🧊 Two Pointers & Sliding Window #2
tpemeja
started this conversation in
Algorithm Checklist
Replies: 1 comment
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Summary
Patterns
Choose
Details
✅ Two Pointers (start/end)
Summary (Key points):
Details
Concept recap:
Generic template:
Case 1: Two Sum II (sorted) — find pair equal to target
Case 2: Container With Most Water — maximize area
Case 3: Trapping Rain Water (two-pointer)
Case 4: 3Sum — unique triplets summing to zero
Case 5: Valid Palindrome (alnum, case-insensitive)
Case 6: Squares of a Sorted Array
Case 7: Count pairs with sum < target (block counting)
Complexity summary:
✅ Fast and slow pointers
Summary (Key points):
Details
Concept recap:
Generic templates:
Case 1: Linked List Cycle — detect if a cycle exists
Case 2: Linked List Cycle II — find the cycle’s entry node
Case 3: Middle of the Linked List
Case 4: Palindrome Linked List
Case 5: Remove Nth Node From End of List — two pointers with a gap
Case 6: Find the Duplicate Number — Floyd over array indices
Case 7: Happy Number — cycle detection on number transform
Pitfalls and tips:
Complexity summary:
✅ Sliding Window (fixed size)
Summary (Key points):
Details
Concept recap:
Generic template:
Case 1: Maximum Average Subarray I — max average of size k
Case 2: Maximum Number of Vowels in a Substring of Given Length
Case 3: Find All Anagrams in a String
Case 4: Permutation in String
Case 5: Number of Sub-arrays of Size K and Average Greater than or Equal to Threshold
Pitfalls:
Complexity summary:
✅ Sliding Window (variable size)
Summary (Key points):
Details
Concept recap:
Generic template:
Case 1: Longest Substring Without Repeating Characters
Case 2: Minimum Size Subarray Sum — positive integers
Case 3: Fruit Into Baskets — at most 2 distinct
Case 4: Longest Repeating Character Replacement
Case 5: Max Consecutive Ones III — flip at most k zeros
Case 6: Subarrays with K Different Integers
Case 7: Binary Subarrays With Sum
Pitfalls and tips:
Complexity summary:
All reactions