Patterns to master DSA
Anonymous User
6368

DS -> Data Structures;
SP -> Sample Problems

-> sliding window
( DS-> array, String, Hashtable;
sample problems -> longest substring with k distinct characters, fruits into bakets)

-> matrix travarsal
(DS-> matrix, queue;
sp -> number of islands, flood fill, cycle in a matrix)

-> two pointer
(DS->array, string, linked list;
sp-> squaring a sorted array, dutch national flag problem, minimum window sort)

-> fast and slow pointers
(DS->array, string, linked list;
sp-> middle of th linked list, happy number, cycle in a circular array)

-> merge intervels
(DS-> array, heap;
sp-> conflict appointments, minimum meeting rooms)

-> cyclic sort
(DS-> array;
sp-> find all missing numbers, find all duplicate numbers, find the first k misssing positive numbers)

-> inplace reversal (linked list)
( DS -> linkedlist;
sp-> reverse everyt k-element, rotate a LL)

-> breadth first search(BFS)
(DS->tree, graph, matrix;
sp-> level order travarsel, depth of tree, connect level order siblings)

-> depth first search(DFS)
(DS->tree, graph, matrix;
sp-> path with given sequence, count paths for a sum)

-> two heaps
(DS-> array, heap;
sp-> find the median of a number stream, next interval)

-> sub sets
(DS-> array, queue, string;
sp-> string permutation by chaining case, unique generalized abbreviation);

-> modified binary search
(Ds-> array;
sp-> ceiling of a number, bitonic array maximum)

-> bitwize XOR
(DS-> array,bits;
sp-> two single numbers, flip and invert an image)

-> top k elements
(DS-> array, queue, heap;
sp-> k closest points to the origin,maximum distinc elements)

-> k-ways merge
(DS-> array, queue, heap;
sp-> kth smallest number in m sorted lists)

-> topological Sort
(DS-> array, Hashtable,queue,graph;
ps-> tasks scheduling, alien dictionary)

-> 0/1 knapsack
(DS-> array, Hashtable;
sp -> equal subset sum partition, minimum subset sum difference)

-> fibonacci numbers
(DS-> array, Hashtable;
sp-> staircase, housee thief)

-> palindromic subsequence
(DS-> array, Hashtable;
sp-> longest palindromic subseaquence, minimum deletions in a string to make palindrome)

-> longest common substring
(DS-> array, Hashtable;
sp-> maximum sum increasing subseaquence, edit distance)

-> segment trees
Lazy Seegment Tree
Sparse Seegment Tree
2D Seegment Tree
Persistence Seegment Tree
(sp -> Range Minimum Query, Count of Longest Increasing Subsequences, Sliding Median)

Comments (11)