Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Two Pointer DSA Patterns

My working repo for mastering the Two Pointer technique — part of a 90-day DSA patterns study plan. Each problem lives in its own folder with its code and a dedicated README explaining the approach.

Structure

two-pointer-dsa/ ├── README.md ├── Progress.md ├── notes/ │ └── two_pointer_mastery.md └── solutions/ ├── 01_palindrome_check/ ├── 02_two_sum_sorted/ ├── 03_longest_palindromic_substring/ ├── 04_remove_duplicates/ ├── 05_merge_sorted_arrays/ ├── 06_linked_list_cycle/ └── 07_middle_of_linked_list/ Each solution folder contains a .py file and its own README.md.

The Three Core Templates

1. Opposite ends (toward each other)

left, right = 0, len(arr) - 1
while left < right:
    ...
    left += 1
    right -= 1

2. Two inputs, exhaust both

i, j = 0, 0
while i < len(a) and j < len(b):
    ...
result.extend(a[i:]); result.extend(b[j:])

3. Fast / slow (same direction)

slow = 0
for fast in range(len(arr)):
    if CONDITION:
        slow += 1
        arr[slow] = arr[fast]

Problems Solved

# Problem Pattern Folder
1 Valid Palindrome Opposite ends 01_palindrome_check/
2 Two Sum II (sorted array) Opposite ends 02_two_sum_sorted/
3 Longest Palindromic Substring Expand around center 03_longest_palindromic_substring/
4 Remove Duplicates from Sorted Array Fast/slow 04_remove_duplicates/
5 Merge Sorted Array Exhaust both 05_merge_sorted_arrays/
6 Linked List Cycle Fast/slow 06_linked_list_cycle/
7 Middle of Linked List Fast/slow 07_middle_of_linked_list/

Practice Backlog

  • 3Sum (LeetCode 15)
  • Container With Most Water (LeetCode 11)
  • Trapping Rain Water (LeetCode 42)
  • Move Zeroes (LeetCode 283)

Running

python solutions/01_palindrome_check/palindrome_check.py

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages