This repository contains a collection of C++ solutions to common data structures and algorithms problems i solved from LEETCODE. The purpose of the project is to practice and demonstrate proficiency in solving coding challenges across multiple problem categories such as arrays, strings, dynamic programming, graphs, trees, and more.
The workspace is organized into folders based on algorithmic patterns and data structures. Each folder groups related problems, allowing for easy navigation and reference:
- arrays/ – array-based problems
- strings/ – string manipulation challenges
- dynamic programming/ – problems involving dynamic programming techniques.
- backtracking/ – backtracking algorithms and combinatorial search problems.
- graphs/ – graph traversal and pathfinding problems.
- trees/ – tree-based algorithms and traversals.
- and more – other categories including greedy, hash table, linked list, sliding window, etc.
Feel free to add your own solutions, improve existing code, or reorganize the structure for clarity. Submit pull requests or create issues for discussion.
-
Two Pointer Technique: This technique is commonly applied on sorted arrays or linked lists to find pairs or reverse elements. It is an ideal strategy when managing elements with pair relationships.
-
Sliding Window: This pattern is used to track a subset of data within a larger dataset. It's particularly useful in array or string problems when you need to maintain a 'window' of elements satisfying a certain condition.
-
Fast & Slow Pointer: Used in linked list or array problems, this pattern is ideal for detecting cycles or finding a midpoint.
-
Merge Intervals: Use this pattern to deal with overlapping intervals, helping to create a more organized and efficient structure.
-
Cyclic Sort: Employed when you need to sort numbers within a defined range, it provides a neat way to ensure ordered data.
-
In-place Reversal of a Linked List: If you need to reverse a linked list in-place, this is the pattern to use.
-
Tree Breadth First Search: Perfect for traversing a tree level-by-level, providing a comprehensive overview of all nodes.
-
Tree Depth First Search: This pattern allows you to traverse a tree or graph using depth as the main factor.
-
Two Heaps: Ideal when dealing with situations that require access to both the smallest and largest elements simultaneously.
-
Subset Pattern (Backtracking): Useful in solving problems related to permutations and combinations.
-
Modified Binary Search: An adaptation of the binary search for situations where a standard binary search doesn't apply.
-
Top 'K' Elements: This pattern is beneficial for problems that require identifying the top or bottom 'k' elements in a set.
-
K-way Merge: Employ this pattern to merge K sorted lists or arrays efficiently.
-
0/1 Knapsack (Dynamic Programming): This dynamic programming pattern is often used for optimization problems.
-
Topological Sort (Graph): Useful in finding a linear ordering of vertices in a directed acyclic graph (DAG).
-
Floyd's Cycle Detection Algorithm: Ideal for finding cycles in data structures such as linked lists or arrays.
-
Kadane’s Algorithm (Dynamic Programming): It's an optimal solution for the maximum subarray problem.
-
Longest Common Subsequence/ Substring (Dynamic Programming): This pattern is handy when finding the longest common subsequence or substring in two strings or arrays.
-
Union Find (Disjoint Set): A data structure used to maintain disjointed sets and is useful for network connectivity problems.
-
Trie (Prefix Tree): Ideal for efficient retrieval of keys in a dataset of strings. It's commonly used for features like autocomplete or spell check.
Happy coding! 💻