Pattern DSA
Pattern DSA
2. Overlapping Intervals
Description: Intervals are often manipulated through sorting and merging based on their start and
end times.
3. Prefix Sum
Description: Prefix Sums/Products are techniques that store cumulative sums or products up to
each index, allowing for quick subarray range queries.
4. Sliding Window
Description: A sliding window is a subarray or substring that moves over data to solve problems
efficiently in linear time.
Fixed Size
● Maximum Sum Subarray of Size K
● Number of Subarrays having Average Greater or Equal to Threshold
● Repeated DNA sequences
● Permutation in String
● Sliding Subarray Beauty
● Sliding Window Maximum
Variable Size
● Longest Substring Without Repeating Characters
● Minimum Size Subarray Sum
● Subarray Product Less Than K
● Max Consecutive Ones
● Fruits Into Baskets
● Count Number of Nice Subarrays
● Minimum Window Substring: Minimum Window Substring
5. Two Pointers
Description: The two pointers technique involves having two different indices move through the
input at different speeds to solve various array or linked list problems.
● Missing Number
● Find Missing Numbers
● Set Mismatch
● First Missing Positive
8. Matrix Manipulation
Description: Problems involving 2D arrays (matrices) are often solved using row-column traversal
or manipulation based on matrix properties.
● Rotate Image
● Spiral Matrix
● Set Matrix Zeroes
● Game of Life
11. Backtracking
Description: Backtracking helps in problems where you need to explore all potential solutions,
such as solving puzzles, generating combinations, or finding paths.
● Permutation ii
● Combination Sum
● Generate Parenthesis
● N-Queens
● Sudoku Solver
● Palindrome Partitioning
● Word Search: Word Search
● Missing Number
● Single Number ||
● Single Number III
● Find the Original array of Prefix XOR
● XOR Queries of a Subarray
18. Trees
Level Order Traversal (BFS in Binary Tree)
● Level order Traversal
● Zigzag Level order Traversal
● Even Odd Tree
● Reverse odd Levels
● Deepest Leaves Sum
● Add one row to Tree
● Maximum width of Binary Tree
● All Nodes Distance K in Binary tree
Tree Construction
● Construct BT from Preorder and Inorder
● Construct BT from Postorder and Inorder
● Maximum Binary Tree
● Construct BST from Preorder
Ancestor problem
● LCA of Binary Tree
● Maximum difference between node and ancestor
● LCA of deepest leaves
● Kth Ancestor of a Tree Node
● House Robber ii
● Target Sum
● Partition Equal Subset Sum
● Ones and Zeroes
● Last Stone Weight ii
● Coin Change
● Coin Change II
● Perfect Squares
● Minimum Cost For Tickets
DP on Grids
Description: Dynamic Programming on matrices involves solving problems that can be broken
down into smaller overlapping subproblems within a matrix.
● Unique Paths ii
● Minimum Path Sum
● Triangle
● Minimum Falling Path Sum
● Maximal Square
● Cherry Pickup
● Dungeon Game: Dungeon Game
DP on Strings
Description: It Involves 2 strings, whenever you are considering two substrings/subsequence from
given two strings, concentrate on what happens when the last characters of the two substrings are
same, i.e, matching.
DP on Stocks
Description: It focuses on maximizing profit from buying and selling stocks over time while
considering constraints.
Partition DP (MCM)
Description: It Involves a sequence that needs to be divided into partitions in an optimal way. The
goal is often to minimize or maximize a cost function, such as computation time, multiplications, or
some other metric, by exploring all possible partitions and combining results from subproblems.
20. Graphs
Topological Sort
Description: Topological sorting is useful for tasks that require dependency resolution (InDegree) in
directed acyclic graphs (DAGs).
● Course Schedule
● Course Schedule II
● Strange Printer ii
● Sequence Reconstruction
● Alien Dictionary
Graph Algorithms
Description: Advanced graph algorithms are used to solve complex problems involving shortest
paths, minimum spanning trees, and graph cycles.
21. Greedy
Description: Greedy algorithms make local optimal choices at each step, which lead to a global
optimal solution for problems like scheduling and resource allocation.
● Jump Game ii
● Gas Station
● Bag of Tokens
● Boats to Save People
● Wiggle Subsequence
● Car Pooling
● Candy