0% found this document useful (0 votes)
7 views21 pages

26 Patterns

The document outlines various coding patterns and problems categorized by techniques such as Two Pointers, Fast & Slow Pointers, Sliding Window, and more. Each pattern includes a list of related problems with varying difficulty levels, from easy to hard, along with links to their respective descriptions. Additionally, it provides a structured approach to learning these patterns, emphasizing the importance of understanding foundational concepts before moving on to more complex topics.

Uploaded by

Mayank
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as XLSX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views21 pages

26 Patterns

The document outlines various coding patterns and problems categorized by techniques such as Two Pointers, Fast & Slow Pointers, Sliding Window, and more. Each pattern includes a list of related problems with varying difficulty levels, from easy to hard, along with links to their respective descriptions. Additionally, it provides a structured approach to learning these patterns, emphasizing the importance of understanding foundational concepts before moving on to more complex topics.

Uploaded by

Mayank
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as XLSX, PDF, TXT or read online on Scribd

Question

1. Pattern: Two Pointers


Pair with Target Sum (easy)
Remove Duplicates (easy)
Squaring a Sorted Array (easy)
Triplet Sum to Zero (medium)
Triplet Sum Close to Target (medium)
Triplets with Smaller Sum (medium)
Subarrays with Product Less than a Target (medium)
Dutch National Flag Problem (medium)
Problem Challenge 1: Quadruple Sum to Target (medium)
Problem Challenge 2: Comparing Strings containing Backspaces (medium)
Problem Challenge 3: Minimum Window Sort (medium)
2. Pattern: Fast & Slow pointers
LinkedList Cycle (easy)
Start of LinkedList Cycle (medium)
Happy Number (medium)
Middle of the LinkedList (easy)
Problem Challenge 1: Palindrome LinkedList (medium)
Problem Challenge 2: Rearrange a LinkedList (medium)
Problem Challenge 3: Cycle in a Circular Array (hard)
3. Pattern: In-place Reversal of a LinkedList
Reverse a LinkedList (easy)
Reverse a Sub-list (medium)
Reverse every K-element Sub-list (medium)
Problem Challenge 1: Reverse alternating K-element Sub-list (medium)
Problem Challenge 2: Rotate a LinkedList (medium)
4. Pattern: Sliding Window
Maximum Sum Subarray of Size K (easy)
Smallest Subarray with a given sum (easy)
Longest Substring with K Distinct Characters (medium)
Fruits into Baskets (medium)
No-repeat Substring (hard)
Longest Substring with Same Letters after Replacement (hard)
Longest Subarray with Ones after Replacement (hard)
Problem Challenge 1: Permutation in a String (hard)
Problem Challenge 2: String Anagrams (hard)
Problem Challenge 3: Smallest Window containing Substring (hard)
Problem Challenge 4: Words Concatenation (hard)
5. Pattern: Hash Maps
First Non-repeating Character (easy)
Largest Unique Number (easy)
Maximum Number of Balloons (easy)
Longest Palindrome(easy)
Ransom Note (easy)
6. Pattern: Stack
Balanced Parentheses
Reverse a String
Decimal to Binary Conversion
Next Greater Element
Sorting a Stack
Simplify Path
7. Pattern: Monotonic Stack
Next Greater Element (easy)
Daily Temperatures (easy)
Remove Nodes From Linked List (easy)
Remove All Adjacent Duplicates In String (easy)
Remove All Adjacent Duplicates in String II (medium)
Remove K Digits (hard)
8. Pattern: Merge Intervals
Merge Intervals (medium)
Insert Interval (medium)
Intervals Intersection (medium)
Conflicting Appointments (medium)
Problem Challenge 1: Minimum Meeting Rooms (hard)
Problem Challenge 2: Maximum CPU Load (hard)
Problem Challenge 3: Employee Free Time (hard)
9. Pattern: Cyclic Sort
Cyclic Sort (easy)
Find the Missing Number (easy)
Find all Missing Numbers (easy)
Find the Duplicate Number (easy)
Find all Duplicate Numbers (easy)
Problem Challenge 1: Find the Corrupt Pair (easy)
Problem Challenge 2: Find the Smallest Missing Positive Number (medium)
Problem Challenge 3: Find the First K Missing Positive Numbers (hard)
10. Pattern: Two Heaps
Find the Median of a Number Stream (medium)
Sliding Window Median (hard)
Maximize Capital (hard)
*Maximum Sum Combinations (medium)
11. Pattern: Top 'K' Elements
Top 'K' Numbers (easy)
Kth Smallest Number (easy)
K' Closest Points to the Origin (easy)
Connect Ropes (easy)
Top 'K' Frequent Numbers (medium)
Frequency Sort (medium)
Kth Largest Number in a Stream (medium)
K' Closest Numbers (medium)
Maximum Distinct Elements (medium)
Sum of Elements (medium)
Rearrange String (hard)
Problem Challenge 1: Rearrange String K Distance Apart (hard)
Problem Challenge 2: Scheduling Tasks (hard)
Problem Challenge 3: Frequency Stack (hard)
*
12. Pattern: K-way merge
Merge K Sorted Lists (medium)
Kth Smallest Number in M Sorted Lists (Medium)
Kth Smallest Number in a Sorted Matrix (Hard)
Smallest Number Range (Hard)
Problem Challenge 1: K Pairs with Largest Sums (hard)
13. Pattern: Subsets
Subsets (easy)
Subsets With Duplicates (easy)
Permutations (medium)
String Permutations by changing case (medium)
Balanced Parentheses (hard)
Unique Generalized Abbreviations (hard)
14. Pattern: Backtracking
Combination Sum (medium)
Word Search (medium)
Sudoku Solver (hard)
Factor Combinations (medium)
Split a String Into the Max Number of Unique Substrings (medium)
15. Pattern : Modified Binary Search
Order-agnostic Binary Search (easy)
Ceiling of a Number (medium)
Next Letter (medium)
Number Range (medium)
Search in a Sorted Infinite Array (medium)
Minimum Difference Element (medium): Find the floor & ceil take the difference, minimum would be the ans
Bitonic Array Maximum (easy)
Problem Challenge 1: Search Bitonic Array (medium)
Problem Challenge 2: Search in Rotated Array (medium)
Problem Challenge 3: Rotation Count (medium)
*Search a 2D Matrix (medium)
*Minimum Number of Days to Make m Bouquets (medium)
*Koko Eating Bananas (medium)
*Capacity To Ship Packages Within D Days (medium)
*Median of Two Sorted Arrays (hard)
16. Pattern: Tree Breadth First Search
Binary Tree Level Order Traversal (easy)
Reverse Level Order Traversal (easy)
Zigzag Traversal (medium)
Level Averages in a Binary Tree (easy)
Minimum Depth of a Binary Tree (easy)
Maximum Depth of a Binary Tree (easy)
Level Order Successor (easy)
Connect Level Order Siblings (medium)
Problem Challenge 1: Connect All Level Order Siblings (medium)
Problem Challenge 2: Right View of a Binary Tree (easy)
17. Pattern: Tree Depth First Search
Binary Tree Path Sum (easy)
All Paths for a Sum (medium)
Sum of Path Numbers (medium)
Path With Given Sequence (medium)
Count Paths for a Sum (medium)
Problem Challenge 1: Tree Diameter (medium)
Problem Challenge 2: Path with Maximum Sum (hard)
18. Pattern: Graphs
Graph Traversal: Depth First Search(DFS)
Graph Traversal: Breadth First Search (BFS)
Find if Path Exists in Graph(easy)
Number of Provinces (medium)
Minimum Number of Vertices to Reach All Nodes(medium)
19. Pattern: Island (Matrix traversal)
Number of Islands (easy)
Biggest Island (easy)
Flood Fill (easy)
Number of Closed Islands (easy)
Problem Challenge 1 (easy)
Problem Challenge 2 (medium)
Problem Challenge 3 (medium)
20. Pattern: Union Find
Redundant Connection (medium)
Number of Provinces (medium)
Is Graph Bipartite? (medium)
Path With Minimum Effort (medium)
21. Ordered Set
Merge Similar Items (easy)
132 Pattern (medium)
My Calendar I (medium)
22. Pattern: Topological Sort (Graph)
Topological Sort (medium)
Tasks Scheduling (medium)
Tasks Scheduling Order (medium)
All Tasks Scheduling Orders (hard)
Alien Dictionary (hard)
Problem Challenge 1: Reconstructing a Sequence (hard)
Problem Challenge 2: Minimum Height Trees (hard)
23. Pattern: Trie
Implement Trie (Prefix Tree) (medium)
Index Pairs of a String (easy)
Design Add and Search Words Data Structure (medium)
Extra Characters in a String (medium)
Search Suggestions System (medium)
24. Pattern: Greedy Algorithms
Valid Palindrome II (easy)
Maximum Length of Pair Chain (medium)
Minimum Add to Make Parentheses Valid (medium)
Remove Duplicate Letters (medium)
Largest Palindromic Number (Medium)
Removing Minimum and Maximum From Array (medium)
25. Pattern : 0/1 Knapsack (Dynamic Programming)
0/1 Knapsack (medium)
Equal Subset Sum Partition (medium)
Subset Sum (medium)
Minimum Subset Sum Difference (hard)
Problem Challenge 1: Count of Subset Sum (hard)
Problem Challenge 2: Target Sum (hard)
26.. Pattern: Bitwise XOR(SOLVE IT JUST AFTER PATTERN 3)
Single Number (easy)
Two Single Numbers (medium)
Complement of Base 10 Number (medium)
Problem Challenge 1: Flip and Invert an Image (hard)

1. Pointer and Linear Data Structures (Arrays, Linked Lists)


Two Pointers

Fast & Slow pointers

In-place Reversal of LinkedList

Reason: All involve direct pointer operations in sequences; understanding this is


critical before moving to advanced manipulation.

2. Windows, Mapping, and Subarrays


Sliding Window

Hash Maps

Reason: Windowing logic builds on linear traversal. Hash Maps are often used
with windowing for frequency, uniqueness, and fast lookups.

3. Stacks and Monotonic Problems


Stack

Monotonic Stack

Reason: Learn basic stack usage, then directly apply it to monotonic scenarios
such as next greater/smaller element problems
4. Sorting and Manipulation, Cyclic Patterns
Merge Intervals

Cyclic Sort

Reason: Both rely on sorting and re-arrangement; these patterns often co-
appear in array manipulation rounds.

5. Heaps and Prioritization Problems


Two Heaps

Top 'K' Elements

K-way Merge

Reason: All use heap/priority queue logic (“highest/lowest N”, efficient multi-
structure processing). K-way naturally follows after mastering Top 'K' and Two
Heaps.

6. Subset Generation & Backtracking


Subsets

Backtracking

Reason: Subset problems introduce combinatorial logic, which generalizes into


the more powerful (and common) backtracking approach for permutations and
combinations.

7. Binary Search and Modifications


Modified Binary Search

Reason: Master basic binary search (often considered assumed knowledge),


then learn modified forms for rotated/search-insert-position problems.

8. Tree Traversal Techniques


Tree Breadth First Search

Tree Depth First Search

Reason: BFS/DFS are fundamental for trees. Learn both sequentially as this
helps with both simple and complex tree problems.

9. Graphs and Related Traversals


Graphs

Island (Matrix Traversal)

Reason: Graphs present adjacency and traversal logic; matrix traversal (islands)
is a direct application in 2D.
10. Component and Structure Problems
Union Find

Ordered Set

Reason: Connectivity (Union Find) naturally follows BFS/DFS, while Ordered Set
builds as a variant for advanced search/tracking—frequently seen in interview
follow-ups.

11. Topological and Specialized Algorithms


Topological Sort (Graph)

Trie

Reason: Move to advanced data structures and ordering algorithms, as these


require confidence in previous traversal and structural knowledge.

12. Optimization, Strategy, and DP


Greedy Algorithms

0/1 Knapsack (Dynamic Programming)

Reason: Learn greedy choice principles, then compare/transition to DP for


optimality (especially for problems where greedy fails and DP is required).
Link 1

[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]

[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]

[Link]
[Link]
[Link]
[Link]
[Link]

[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]

[Link]
[Link]
[Link]
[Link]
[Link]

[Link]
[Link]

[Link]

[Link]
[Link]
[Link]
[Link]
[Link]
[Link]

[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]

[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]

[Link]
[Link]
[Link]
[Link]

[Link]

[Link]

[Link]
[Link]

[Link]
[Link]
[Link]
[Link]

[Link]
[Link]
[Link]

[Link]

[Link]
[Link]
[Link]
[Link]
[Link]

[Link]
[Link]
[Link]
[Link]
[Link]
difference, minimum would be the ans
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]

[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]

[Link]
[Link]
[Link]

[Link]

[Link]
[Link]

[Link]
[Link]
[Link]
[Link]

[Link]
[Link]
[Link]

[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]

[Link]
[Link]
[Link]
[Link]
[Link]

[Link]
[Link]
[Link]
[Link]
[Link]
[Link]

[Link]
[Link]
[Link]
[Link]
Link 2 Link 3

[Link]
[Link]

ler-than-x5549/1

[Link]
[Link] [Link]

[Link] [Link]

ng-a-given-set-of-intervals/

ues-in-on-using-cycle-sort/

oding-Questions/blob/master/13.-pattern-top-k-elements/[Link]
oding-Questions/blob/master/13.-pattern-top-k-elements/[Link]

[Link] [Link]
[Link]

unique-substrings/

[Link]

n-sorted-array/
nite-numbers/

-which-is-first-increasing-and-then-decreasing/
[Link]

[Link] [Link]
hat-the-difference-of-subset-sums-is-minimum/
blems/remove-duplicates-from-sorted-array-ii/
blems/next-greater-element-iv/

blems/next-greater-element-iv/
blems/combination-sum-iii/
blems/my-calendar-iii/

You might also like