Skip to content

A collection of reusable code snippets that can be used for code interview problems

License

Notifications You must be signed in to change notification settings

Abhi001vj/coding-interview-preparation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

coding-interview-preparation

A collection of reusable code snippets that can be used for code interview problems

Pattern Implementation Status

✅ = Fully Implemented 🔄 = In Progress ⏳ = Planned

Core Patterns

  1. ✅ Prefix Sum
  2. ✅ Two Pointers
  3. ✅ Sliding Window
  4. ✅ Fast & Slow Pointers
  5. ✅ LinkedList Reversal
  6. ✅ Monotonic Stack
  7. ✅ Top K Elements
  8. ✅ Overlapping Intervals
  9. ✅ Modified Binary Search
  10. ✅ Tree Traversal
  11. ✅ DFS
  12. ✅ BFS
  13. ✅ Matrix Traversal
  14. ✅ Backtracking
  15. ✅ Basic Dynamic Programming

Dynamic Programming Patterns

  1. ✅ Fibonacci Sequence
  2. ✅ Kadane's Algorithm
  3. ✅ 0/1 Knapsack
  4. ✅ Unbounded Knapsack
  5. ✅ LCS
  6. ✅ LIS
  7. ✅ Palindromic Subsequence
  8. ✅ Edit Distance
  9. ✅ Subset Sum
  10. ✅ String Partition
  11. ✅ Catalan Numbers
  12. ✅ Matrix Chain Multiplication
  13. ✅ Count Distinct Ways
  14. ✅ Grid DP
  15. ✅ Tree DP
  16. ✅ Graph DP
  17. ✅ Digit DP
  18. ✅ Bitmasking DP
  19. ✅ Probability DP
  20. ✅ State Machine DP

Resources

Official Documentation

Inspirational Articles

  1. 15 LeetCode Patterns by Ashish Pratap Singh
  2. 20 Patterns to Master Dynamic Programming by Ashish Pratap Singh

Practice Platforms

  • LeetCode
  • HackerRank
  • CodeForces

📖 Resources & Inspiration

Primary Sources

  1. "LeetCode was HARD until I Learned these 15 Patterns" by Ashish Pratap Singh

    • Comprehensive coverage of core algorithmic patterns
    • Practical examples and problem classifications
    • Pattern-based problem-solving approach
  2. "20 Patterns to Master Dynamic Programming" by Ashish Pratap Singh

    • In-depth coverage of DP patterns
    • Pattern categorization from basic to advanced
    • Problem-pattern mapping for DP

Additional Learning Resources

Official Documentation

Practice Platforms

Books & Articles

  • "Introduction to Algorithms" (CLRS)
  • "Algorithms" by Robert Sedgewick
  • "Dynamic Programming for Coding Interviews"

Video Resources

  • AlgoMaster YouTube Channel
  • Back To Back SWE
  • Tech Interview Pro

🤝 Contributing

We welcome contributions! Please see our CONTRIBUTING.md for details on:

  • Adding new patterns
  • Improving implementations
  • Adding problem solutions
  • Enhancing documentation

Pattern Selection Guide

How to Choose the Right Pattern

  1. Identify Key Characteristics:

    • Sorted array? → Two Pointers
    • Substring/Subarray? → Sliding Window
    • Optimal substructure? → Dynamic Programming
  2. Consider Constraints:

    • Time complexity requirements
    • Space complexity limits
    • Input size ranges
  3. Common Pattern Indicators:

    def select_pattern(characteristics: Dict[str, bool]) -> str:
        if characteristics.get('sorted_array'):
            return 'Two Pointers'
        elif characteristics.get('subarray_sum'):
            return 'Prefix Sum'
        elif characteristics.get('optimization'):
            return 'Dynamic Programming'
        # ... more conditions

Best Practices

  1. Time Complexity:

    • Always consider the most efficient solution
    • Document complexity in comments
    • Explain trade-offs
  2. Space Optimization:

    • Consider in-place algorithms when possible
    • Use space-time trade-offs wisely
    • Document space complexity
  3. Code Style:

    • Follow Google Python Style Guide
    • Use meaningful variable names
    • Add comprehensive docstrings

Contributing

Contributions are welcome! Please:

  1. Follow the code style guide
  2. Add comprehensive tests
  3. Document complexity analysis
  4. Include example problems
  5. Update implementation status

License

MIT License - see LICENSE file for details.


Happy Coding! 🚀

Ultimate Algorithm Patterns Guide

A comprehensive collection of coding interview patterns combining algorithmic techniques and dynamic programming approaches.

📚 Table of Contents

  1. Introduction

    • Purpose
    • How to Use This Guide
    • Repository Structure
  2. Core Algorithm Patterns

    • Array & String Patterns
      • Prefix Sum
      • Two Pointers
      • Sliding Window
    • Linked List Patterns
      • Fast & Slow Pointers
      • In-place Reversal
    • Stack & Queue Patterns
      • Monotonic Stack
      • Priority Queue (Top K)
    • Binary Search Patterns
      • Modified Binary Search
      • Search Space Reduction
    • Tree & Graph Patterns
      • Tree Traversals (PreOrder, InOrder, PostOrder)
      • BFS/DFS
      • Matrix Traversal
    • Advanced Patterns
      • Backtracking
      • Intervals
      • Cyclic Sort
  3. Dynamic Programming Patterns

    • Basic Patterns
      • Fibonacci Style
      • Kadane's Algorithm
    • Knapsack Patterns
      • 0/1 Knapsack
      • Unbounded Knapsack
    • String Patterns
      • LCS (Longest Common Subsequence)
      • LIS (Longest Increasing Subsequence)
      • Palindromic Subsequences
      • Edit Distance
    • Grid & Graph Patterns
      • Grid Traversal
      • Tree DP
      • Graph DP
    • Advanced DP Patterns
      • State Machine
      • Probability DP
      • Digit DP
      • Bitmask DP
  4. Pattern Recognition Guide

    • How to Identify Patterns
    • Common Problem Types
    • Pattern Selection Flowchart
  5. Implementation Guidelines

    • Code Style
    • Best Practices
    • Complexity Analysis
    • Testing Strategies
  6. Problem Collection

    • LeetCode Problems by Pattern
    • Common Variations
    • Solution Templates
  7. Study Guide

    • Learning Path
    • Practice Strategy
    • Interview Preparation Tips

About

A collection of reusable code snippets that can be used for code interview problems

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages