Skip to content

Tyagirohan/LeetCode-Patterns

Repository files navigation

🎯 LeetCode Patterns - Week 4

Status Projects Week

Master 6 patterns that unlock 300+ LeetCode problems

Interactive visualizers for the most common coding interview patterns. Each project includes animated step-by-step walkthroughs, multiple problem examples, and real-world applications.


πŸš€ Live Projects

Day 1: Fast & Slow Pointers 🐒🐰

Pattern: Floyd's Cycle Detection (Tortoise & Hare)

Detect cycles and find duplicates using two pointers moving at different speeds.

Key Features:

  • Animated tortoise & hare visualization
  • Cycle detection in linked lists
  • Find duplicate number algorithm
  • Happy number checker
  • Interactive custom list builder

Problems Solved:

  • Linked List Cycle (LeetCode 141, 142)
  • Find Duplicate Number (LeetCode 287)
  • Happy Number (LeetCode 202)
  • Middle of Linked List (LeetCode 876)

Real-World Use: Memory leak detection, loop detection, duplicate detection in streams

πŸ”— Live Demo | πŸ“‚ Code

Tech Stack: Vanilla JS, Canvas API, O(n) time, O(1) space


Day 2: Merge Intervals πŸ“Š

Pattern: Sort + Merge Overlapping Ranges

Schedule meetings, merge time intervals, and solve resource allocation problems.

Key Features:

  • Timeline visualization with animated merging
  • 4 problem types (Merge, Insert, Meeting Rooms, Non-overlapping)
  • Interactive custom interval input
  • Quick presets (Calendar, Busy Schedule, Sparse, Complex)
  • Real-time stats tracking
  • Color-coded intervals and merges

Problems Solved:

  • Merge Intervals (LeetCode 56)
  • Insert Interval (LeetCode 57)
  • Meeting Rooms I & II (LeetCode 252, 253)
  • Non-overlapping Intervals (LeetCode 435)
  • Interval List Intersections (LeetCode 986)

Real-World Use: Calendar apps (Google Calendar), resource scheduling, timeline management, booking systems

πŸ”— Live Demo | πŸ“‚ Code

Tech Stack: Vanilla JS, Canvas API, O(n log n) time


Day 3: Backtracking β™ŸοΈ

Pattern: Try β†’ Check β†’ Recurse β†’ Backtrack

Solve N-Queens and Sudoku puzzles with animated decision tree exploration.

Key Features:

  • N-Queens solver (4x4 to 8x8 boards)
  • Sudoku solver with 4 difficulty levels
  • Animated backtracking visualization
  • Multiple solutions viewer (N-Queens)
  • Real-time statistics (attempts, backtracks, solutions)
  • Speed control and step-by-step mode

Problems Solved:

  • N-Queens (LeetCode 51, 52)
  • Sudoku Solver (LeetCode 37)
  • Permutations (LeetCode 46)
  • Subsets (LeetCode 78)
  • Generate Parentheses (LeetCode 22)

Real-World Use: Game AI, puzzle solvers, constraint satisfaction, scheduling, resource allocation

πŸ”— Live Demo | πŸ“‚ Code

Tech Stack: Vanilla JS, Canvas API, O(b^d) complexity


Day 4: Top K Elements πŸ†

Pattern: Heap / Priority Queue for Efficient Top K

Find top K elements using min/max heaps - faster than full sorting!

Key Features:

  • Kth largest element finder
  • Top K frequent elements
  • K closest points to origin
  • Heap structure visualization
  • Array and comparison views
  • Real-time performance comparison

Problems Solved:

  • Kth Largest Element (LeetCode 215)
  • Top K Frequent Elements (LeetCode 347)
  • K Closest Points (LeetCode 973)
  • Find Median from Stream (LeetCode 295)

Real-World Use: Leaderboards, recommendations, search ranking, OS task scheduling

πŸ”— Live Demo | πŸ“‚ Code

Tech Stack: Vanilla JS, Heap implementation, O(n log k) time


Day 5: Binary Tree Patterns 🌳

Pattern: DFS/BFS Traversals & Path Problems

Master all tree traversal types with interactive visualization and path finding.

Key Features:

  • 5 traversal types (Inorder, Preorder, Postorder, Level Order, Zigzag)
  • Interactive tree builder
  • Path sum calculator
  • Animated step-by-step traversal
  • Color-coded visualization
  • Real-time result display

Problems Solved:

  • Binary Tree Traversals (LeetCode 94, 144, 145, 102)
  • Path Sum (LeetCode 112, 113)
  • Zigzag Level Order (LeetCode 103)
  • Lowest Common Ancestor (LeetCode 236)

Real-World Use: File systems, DOM manipulation, org hierarchies, compilers, databases

πŸ”— Live Demo | πŸ“‚ Code

Tech Stack: Vanilla JS, Canvas API, O(n) traversals


Day 6: Subsets & Permutations πŸ”„

Pattern: Generate All Combinations

Generate all subsets, permutations, and combinations with decision tree visualization.

Key Features:

  • Subsets generator (2^n combinations)
  • Permutations generator (n! arrangements)
  • Combinations (choose K from N)
  • Real-time result display in grid
  • Expected count calculator
  • Exponential growth demonstration

Problems Solved:

  • Subsets (LeetCode 78, 90)
  • Permutations (LeetCode 46, 47)
  • Combinations (LeetCode 77)
  • Combination Sum (LeetCode 39)

Real-World Use: Password generation, test cases, feature flags, A/B testing, menu planning

πŸ”— Live Demo | πŸ“‚ Code

Tech Stack: Vanilla JS, Recursive backtracking, O(2^n) / O(n!) complexity


πŸ“š Pattern Coverage

These 6 patterns solve 300+ LeetCode problems:

Pattern Problems Difficulty Time Complexity
Fast & Slow Pointers ~30 Easy-Medium O(n)
Merge Intervals ~40 Medium O(n log n)
Backtracking ~50 Medium-Hard O(2^n)
Top K Elements ~40 Medium O(n log k)
Tree Patterns ~100+ Easy-Hard O(n)
Subsets/Permutations ~50 Medium O(2^n)

🎯 Learning Path

Week 1: Data Structures

Built the building blocks (Stack, Queue, Hash Map, Linked List, Tree, Graph)

Week 2: Core Algorithms

Implemented fundamental algorithms (Binary Search, Two Pointers, Merge Sort, Dijkstra's, DP)

Week 3: Real-World Applications

Created production tools (Git Diff, Autocomplete, GPS, Calculator, Compressor, Load Balancer)

Week 4: LeetCode Patterns ← You Are Here!

Master interview patterns that unlock hundreds of problems


πŸ’‘ Why Patterns Matter

Instead of memorizing 1000 problems, learn 6 patterns:

  • βœ… Recognition: See a problem β†’ Know the pattern
  • βœ… Application: Apply pattern β†’ Solve similar problems
  • βœ… Interview Ready: Most FAANG questions use these patterns
  • βœ… Efficiency: Solve 300+ problems with 6 techniques

πŸ› οΈ Tech Stack

  • Frontend: HTML5, CSS3, Vanilla JavaScript (ES6+)
  • Visualization: Canvas API, CSS Animations
  • Hosting: GitHub Pages
  • Philosophy: No frameworks, pure understanding

πŸ“– How to Use

  1. Watch: See the algorithm animate step-by-step
  2. Interact: Try custom inputs and test cases
  3. Learn: Understand when to apply each pattern
  4. Practice: Solve linked LeetCode problems
  5. Master: Recognize patterns in new problems

🎨 Project Features

Every project includes:

  • βœ… Interactive visualization (animated)
  • βœ… Multiple problem examples (3-4 per pattern)
  • βœ… Speed control (slow/normal/fast/instant)
  • βœ… Custom input (test your own cases)
  • βœ… Code walkthrough (see algorithm execute)
  • βœ… Time/Space complexity analysis
  • βœ… Pattern recognition guide
  • βœ… LeetCode problem links

πŸ“Š Progress Tracker

  • Day 1: Fast & Slow Pointers βœ…
  • Day 2: Merge Intervals βœ…
  • Day 3: Backtracking βœ…
  • Day 4: Top K Elements βœ…
  • Day 5: Binary Tree Patterns βœ…
  • Day 6: Subsets & Permutations βœ…

πŸŽ‰ Week 4 Complete!


πŸ”— Previous Series


πŸš€ Getting Started

  1. Clone the repository
git clone https://github.com/Tyagirohan/LeetCode-Patterns.git
cd LeetCode-Patterns
  1. Open any project
cd day01-fast-slow-pointers
# Open index.html in your browser
  1. No build step needed - pure HTML/CSS/JS!

🎯 Interview Preparation

After completing this series, you'll be able to:

  • βœ… Recognize patterns in new problems
  • βœ… Know which pattern to apply
  • βœ… Implement solutions efficiently
  • βœ… Explain your approach clearly
  • βœ… Handle follow-up questions

πŸ“± Connect

Built by Rohan Tyagi

πŸ”— GitHub | πŸ’Ό LinkedIn


πŸ“„ License

MIT License - Feel free to use for learning!


Master patterns, not problems 🎯

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors