Tags

  • ⭐ = solved in first try
  • 📍 = revisit
  • 🔥 = important
  • ⚠️ = solved but edge case missed
  • 👀 = solved but had to see little soluation first
  • 💀 = out of the box
  • no tag = pending/not started

1. Pattern: Two Pointers

QuestionTagsRememberMy Soluation
1. Pair with Target Sum (easy)if only small char in string then we can use freq map1. Two Sum
2. Rearrange 0 and 1 (easy)
3. Remove Duplicates (easy)
4. Squaring a Sorted Array (easy)
5. Triplet Sum to Zero (medium)⚠️ 📍reperating number condition2. 3Sum 4Sum
6. Triplet Sum Close to Target (medium)
7. Triplets with Smaller Sum (medium)
8. Dutch National Flag Problem (medium)like merge sort..
mid for curr
000 mid 222

s should be stored with 0
and e should be sorted with 2
4. Dutch National Flag Algo
9. 4Sum (medium)reperating number condition2. 3Sum 4Sum
10. Backspace String Compare (medium)📍
11. Shortest Unsorted Continuous Subarray (medium)📍till s sorted
from e sorted
but edge case where the unsorted part might not be actually unsorted. so find max and min in that and then decrease our s and inc e to make up to the max and min

2. Pattern: Fast & Slow pointers

QuestionTagsRememberMy Soluation
1. LinkedList Cycle (easy)
2. Start of LinkedList Cycle (medium)💀📍the maths behind it
2 (slow) = fast
2 (P + C - X) = P + C - X + C
5. LinkedList Cycle
3. Happy Number (medium)💀📍you get to see same number again for sure
2 4 8 16 8
4. Find the Duplicate Number (medium)💀📍Logic behind it:
Array values in range [1, n], so no element points to index 0. Index 0 is guaranteed to be outside the cycle, making it the perfect starting point to detect the duplicate (cycle entrance).
5. LinkedList Cycle
5. Middle of the LinkedList (easy)Floyd Cycle Detection Alog
6. Palindrome Linked List (medium)
7. Reorder List (medium)
8. Circular Array Loop (hard)