0% found this document useful (0 votes)
324 views

Most Common Leetcode DSA Patterns

The document provides an overview of common data structures and algorithms used to solve different types of problems in data structure and algorithms interviews. It lists binary search, two pointers, backtracking, depth-first search, breadth-first search, two pointers, stack, queue, swap, dynamic programming, heap, map, trie, sorting as common approaches for problems involving sorted arrays, permutations, trees, graphs, linked lists, recursion bans, in-place solutions, maximum/minimum subproblems, top K items, and common strings respectively. It encourages connecting with the author for more problem solving insights.

Uploaded by

KARTIKEY GARG
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
324 views

Most Common Leetcode DSA Patterns

The document provides an overview of common data structures and algorithms used to solve different types of problems in data structure and algorithms interviews. It lists binary search, two pointers, backtracking, depth-first search, breadth-first search, two pointers, stack, queue, swap, dynamic programming, heap, map, trie, sorting as common approaches for problems involving sorted arrays, permutations, trees, graphs, linked lists, recursion bans, in-place solutions, maximum/minimum subproblems, top K items, and common strings respectively. It encourages connecting with the author for more problem solving insights.

Uploaded by

KARTIKEY GARG
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

MOST Common

DSA Patterns
Solve Maximum problems!

Swipe >>
If input array is sorted then :
Binary Search, Two Pointers.
If asked for all
permutations/subsets then :
Backtracking.
If given a Tree/Graph then :
DFS & BFS.
If given a linked list then :
Two Pointers.

Swipe >>
If recursion is banned then :
Stack, Queue.
If must solve in-place then :
- Swap corresponding values
- Store one or more different values
in the same pointer.
If asked for maximum/minimum
subarray/subset/options then :
Dynamic programming
.
Swipe >>
If asked for top/least K items :
Heap.
If asked for common strings then :
Map, Trie.
Others :
- Map/Set for O(1) time & O(n) space.
- Sort input for O(nlogn) time and
O(1) space.

Swipe >>
Thanks
We missed something?

Connect with Achintya Gaumat for


more such insights!

You might also like