Welcome to DSAlgoPatterns, a structured collection of Data Structures and Algorithms (DSA) problems designed to help you build problem-solving intuition across C++, Python, and Java.
Each topic follows a pattern-based approach, ensuring you recognize and apply solutions effectively. Every problem includes:
- Solutions in C++, Python, and Java
- An explanation (
.md
file) for clarity - Key concepts and approaches
- Real-world analogy
This repository is built to be a self-sustained learning resource, whether you're preparing for coding interviews, competitive programming, or improving problem-solving skills.
π’ Beginner | π‘ Intermediate | π΄ Advanced
- Subarrays/Substrings π‘
- Maximum Subarray (Kadane's) π’ (Added)
- Minimum Window Substring π΄
- Longest Substring Without Repeating π‘
- Frequency Counting π’
- Two Sum π’
- Two Sum II (Input Sorted) π’
- Group Anagrams π‘
- Top K Frequent Elements π‘
- Prefix Sum & Hashing π‘
- Find Middle Index in Array π’
- Product Except Self π‘
- Maximum Product Subarray π‘
- Number of Ways to Split Array π‘
- Range Sum Query 2D π‘
- Collision Pointers π‘
- Container with Most Water π‘
- Trapping Rain Water π΄
- 3Sum π‘
- Fast & Slow Pointers π‘
- Linked List Cycle II π‘
- Remove Nth Node from End π‘
- Find the Duplicate Number π‘
- Palindrome Linked List π’
- In-place Reversal π‘
- Reverse Linked List π’
- Reverse Nodes in k-Group π΄
- Swap Nodes in Pairs π‘
- Rotate Array π‘
- Dutch National Flag π‘
- Sort Colors π‘
- Classic Binary Search π’
- Rotated Arrays π‘
- Answer Optimization π‘
- Capacity to Ship Packages π‘
- Koko Eating Bananas π‘
- Split Array Largest Sum π΄
- Advanced π΄
- Fixed Size π‘
- Variable Size π‘
- Monotonic Queue/Stack π΄
- Permutations π‘
- Permutations I & II π‘
- N-Queens π΄
- Sudoku Solver π΄
- Combinations π‘
- Combination Sum I & II π‘
- Generate Parentheses π‘
- Subsets π‘
- Subsets I & II π‘
- Palindrome Partitioning π‘
- Word Search π‘
- BFS π‘
- Shortest Path in Binary Matrix π‘
- Rotten Oranges π‘
- As Far From Land as Possible π‘
- Word Ladder π΄
- DFS π‘
- Number of Islands π‘
- Number of Closed Islands π‘
- Coloring a Border π‘
- Number of Enclaves π‘
- Time Needed to Inform All Employees π‘
- Advanced Algorithms π΄
- Dijkstra's Shortest Path π΄
- Topological Sort π΄
- Kruskal's (Union-Find) π΄
- Union-Find π‘
- Redundant Connection π‘
- Number of Provinces π‘
- Accounts Merge π‘
- Knapsack Variants π‘
- Subset Sum π‘
- Coin Change π‘
- Target Sum π‘
- Partition Equal Subset Sum π‘
- Ones and Zeroes π‘
- Longest Increasing Subsequence (LIS) π‘
- Standard LIS π‘
- Russian Doll Envelopes π΄
- House Robber Series π‘
- House Robber I & II π‘
- Last Stone Weight II π‘
- Grid Problems π‘
- Unique Paths π‘
- Minimum Path Sum π‘
- Dungeon Game π΄
- String DP π‘
- Longest Common Subsequence π‘
- Edit Distance π‘
- Interleaving String π‘
- Matrix Chain π΄
- XOR Tricks π‘
- Bitmasking π‘
- Subset Generation π‘
- N-Queens (Bitmask) π΄
- Maximum Product of Word Lengths π‘
- Arithmetic π’
- Add Without Arithmetic Operators π‘
- Power of Two π’
- Reverse Bits π’
- Number Theory π‘
- GCD & LCM π’
- Prime Checks π‘
- Perfect Squares π‘
- Coordinate Geometry π‘
- Overlapping Rectangles π‘
- Convex Hull π΄
- K Closest Points to Origin π‘
- Matrix Operations π‘
- Rotate Image π‘
- Spiral Matrix π‘
- Set Matrix Zeroes π‘
- Game of Life π‘
- Top K & K-way Merge π‘
- Top K Frequent Elements π‘
- Kth Largest Element π‘
- Ugly Number II π‘
- Merge K Sorted Lists π΄
- Monotonic Stack π‘
- Daily Temperatures π‘
- Next Greater Element II π‘
- Next Greater Node in Linked List π‘
- Online Stock Span π‘
- Maximum Width Ramp π‘
- Largest Rectangle in Histogram π΄
- Two Heaps π΄
- Find Median from Data Stream π΄
- Sliding Window Median π΄
- IPO π΄
- Tree Traversals π‘
- Level Order Traversal π’
- Zigzag Level Order π‘
- Even Odd Tree π‘
- Deepest Leaves Sum π‘
- Tree Construction π‘
- Advanced Tree Problems π΄
- All Nodes Distance K π‘
- Add One Row to Tree π‘
- Maximum Width of Binary Tree π‘
- Validate BST π‘
- Trie π‘
- Implement Trie π‘
- Word Search II π΄
- Design Add & Search Words π‘
- Greedy π‘
- Jump Game II π‘
- Gas Station π‘
- Bag of Tokens π‘
- Boats to Save People π‘
- Wiggle Subsequence π‘
- Candy π΄
- Design Data Structures π‘
- LRU Cache π‘
- LFU Cache π΄
- Design Twitter π‘
- Design Browser History π‘
- Design Circular Deque π‘
- Snapshot Array π‘
- Each topic folder contains problems implemented in three languages.
- Every problem has an accompanying
.md
file explaining approaches, time complexity, and best pr actices.
- Pick a pattern-based topic from the
Topics Covered
section. - Read the theory (if available) before solving problems.
- Solve problems in your preferred language (C++, Python, Java).
- Refer to the explanation (
.md
file) if needed. - Compare implementations across languages to recognize common patterns.
- Revisit problems periodically for retention.
(β‘ More topics will be added as we progress!)
Language | Key Considerations |
---|---|
C++ | STL (vector , set , unordered_map , priority_queue ) is useful. Efficient memory management is key. |
Python | List comprehensions, collections module, and heapq simplify solutions. Python's recursion depth needs handling. |
Java | Uses ArrayList , HashMap , and PriorityQueue . Extra attention to handling large numbers and recursion stack size. |
Tip: If you're learning all three languages, compare implementations to spot similarities and differences!
πΉ Planned Additions:
- π More problems covering all patterns.
- π Code optimizations and best practices.
- π Company-wise problem tagging (Google, Amazon, etc.).
- π Adding video explanations for complex topics.
- π Interactive challenges and quizzes for learning reinforcement.
- π LeetCode, CodeChef, and CodeForces problem mapping.
- π Performance analysis of different approaches.
πΉ This repository is a work in progress and will keep evolving. If it helps you, drop a β on GitHub!
π Let's crack DSA, one pattern at a time! π