DSA Sheet Final
DSA Sheet Final
Question Link
Stacks
1 Next Greater Element on right
2 Next Greater Element 2
3 Daily Temperatures
4 maximum difference between left and right smaller
5 Stock Span Problem
6 Largest Rectangular Area Histogram
7 maximu size binary matrix containing 1
8 Valid Parentheses
9 Length of longest valid substring
10 Count of duplicate Parentheses
11 Decode String
12 Minimum Add To make Parentheses Valid
13 Print Bracket Number
14 Asteroid Collision
15 Backspace String Compare
16 Print Binary Number
17 Score Of String
18 Remove K digits From number
19 Car fleet
20 First negative Integer in k sized window
21 Addition
22 Gas Station
23 Maximum sum of smallest and second smallest
24 Min Stack
25 K stacks in a single array
26 Validate Stack
27 K reverse in a queue
28 largest Pair sum in unsorted array
Linked Lists
1 reverse LinkedList
2 K reverse
3 Floyd cycle
4 Merge LinkedList
5 Clone a linkedlist
6 find modular node
7 Remove duplicate from sorted
8 Find the middle element
9 Nth element from end
10 LRU Cache
Binary Tree
1 Inorder Traversal
2 Preorder Traversal
3 Postorder Traversal
4 Print ancestor of given tree
5 Binary Tree Level Order
6 Average of levels
7 All Nodes at distance K
8 Count bst in a given range
9 Binary search tree to greater sum
10 Binary Tree Cameras
11 Binary Tree Maximum Path Sum
12 Binary Tree to BST
13 right side view
14 Left View
15 Vertical order
16 Top View
17 Bottom View
18 Diagonal Traversal
19 leftmost and rightmost node
20 kth smallest element
21 Binary Tree Tilt
22 Print all nodes that dont have siblings
23 House robber 3
24 Boundary Traversal
14 Rabbits in forest
Heap
1 Binary heap
2 Build heap from array
3 Island perimeter
4 skyline problem
5 Pairs of coinciding points
6 trapping rain water
7 Trapping Rain Water II
8 Sort a nearly sorted array
9 bulb switcher
10 max frequency stack
11 Sliding window maximum
12 Swim in rising water
13 Heap sort
14 Product of Array Except Self
15 K empty slots
16
17 mathematics
18
19 Sieve of Eratosthenes
20 Segmented sieve
21 Squares of a Sorted Array
22 Fast Exponentiation
23 Fibonacci Number
24 Container With Most Water
1 Segregate 0 and 1
2 Segregate 0-1-2
3 Sort Array By Parity
4 MIn Jump required with +i or -i allowed
5 Max chunks to make sorted
6 Max Chunks To Make Sorted II
7 Two Sum
8 Two Difference
9 LPS
10 Shortest Palindrome
11 Boats to Save People
12 Min No. of Platform
13 Maximum Swap
14 Optimal Division
15 Max Consecutive Ones II
16 max consecutive ones 3
17 majority element
18 majority element 2
19 majority element general
20 Reverse vowels of a string
21 First missing positive
22 push dominoes
23 moving stones until consecutive 2
24 max product of 3 numbers
25 largest number atleast twice of others
26 maximum product subarray
27 rotate image
28 number of subarrays with bounded maximum
29 partition labels
30 global and local inversions
31 partition array into disjoint intervals
32 valid pallindrome 2
33 consecutive number sum
34 minimum domino rotation for equal row
35 multiply strings
36 smallest range from k lists
37 pascal triangle 2
38 max sum of two non overlapping subarrays
39 maximize distance to closest person
40 Subarrays with k different integers
41 Icing on cake
42 search in rotated sorted array
43 split array largest sum
44 counting sort
45 capacity to ship within D days
46 insertion sort
47 koko eating bananas
48 median of two sorted array
49 merge sort
50 smallest divisor given a threshold
51 wiggle sort
52 best meeting points
Graph
1 BFS of graph
2 Bipartite graph
3 DFS
4 detect cycle in undirected graph
5 Prim's Algo
6 Dijkstra algo
7 chef and reversing
8 Bus routes
9 evaluate division
10 topological sorting
11 Kahn's algo
12 course schedule 2
13 Strongly Connected Components (Kosaraju's Algo)
14 Mother Vertex
15 Rotting Oranges
16 bellman ford
17 Number of Islands
18 DSU
19 Number of Enclaves
20 Most Stones Removed with Same Row or Column
21 Regions Cut By Slashes
22 Kruskal's algo
23 Articulation point
24 Doctor Strange
25 Satisfiability of Equality Equations
26 0-1 matrix
27 Word Ladder
28 Job Sequencing
29 Eulerian Path in an Undirected Graph
30 Euler Circuit in a Directed Graph
31 Castle RUN
32 Sentence Similarity II
33 Number of Distinct Islands
34 Number of Islands II
35 Parallel courses
36 optimize water distribution in village
37 connecting cities with minimum cost
Dynamic programming
BFS/DFS
Sliding Puzzle
1 Find the Maximum Flow
2 Maximum Bipartite Matching
3 Reconstruct Itinerary
4 Redundant Connection
5 Redundant connection 2
6 Possible Bipartition
7 Floyd Warshall
8 Johnson's algorithm
9 Journey to the moon
10 Sort item by group accord to dependencies
11 As far from land as possible
11 K-Similar Strings
12 Similar String Groups
13 Coloring A Border
14 Shortest bridge
15 Min swaps required to sort array
16 Walls and gates
17 The maze 2
Text processing
1 KMP
2 Find string roots
3 Z algo
4 chef and secret password
5 Manacher's algo
Number theory
1 Euclidean algorithm
2 Extended Euclidean algorithm
3 Linear diaophantine equation
4 Euler's totient function
5 Divisors upto n
6 Fermat's little theorem
7 No min No max
8 Boring factorials
9 FFT
Geometry
1 Erect the fence
Game Theory
1 5 Pirates and 100 coins
2 Nim game
3 Buddy nim
Subproblem of what?
https://www.youtube.com/watch?
v=lJwbPZGo05A
the left and right are saved and left is turend into none and the saved left is now the right of the root and the orgiinal right is n
iterate the code to understand no other option at date 20/6/22
for python code-https://www.youtube.com/wat
HINT
genreal concept for using stack foundation of problems below in the list
genreal concept for using stack foundation of problems below in the list
genreal concept for using stack foundation of problems below in the list slight variation of remembering index
genreal concept for using stack foundation of problems below in the list
Putting indexes in the stack not values
https://www.youtube.com/watch?v=jC_cWLy7jSI
https://leetcode.com/problems/maximal-rectangle/discuss/1255410/Python-Based-on-Maximum-Rectangle-in-Histogram-Clean
https://leetcode.com/problems/valid-parentheses/
https://www.youtube.com/watch?v=qB0zZpBJlh8
if stack is empty just add the time.if the previous car in the stack is more time, than it is added to stack since it wont catch up to
https://www.youtube.com/watch?v=qq64FrA2UXQ
C:\Users\Vora\Documents\gas station.docx
https://www.youtube.com/watch?v=EPxaQgnxLfE
https://www.youtube.com/watch?v=xDEuM5qa0zg,…..........................https://www.youtube.com/watch?v=NDpwj0VWz1U
https://www.youtube.com/watch?v=nPtARJ2cYrg
https://www.youtube.com/watch?v=uoFrIIrp5_g
https://www.youtube.com/watch?v=nHR8ytpzz7c
https://www.youtube.com/watch?v=_-QHfMDde90
https://www.geeksforgeeks.org/sqrt-square-root-decomposition-technique-set-1-introduction/ …..................................... http
https://www.youtube.com/watch?v=kouxiP_H5WE
https://www.youtube.com/watch?v=aZNaLrVebKQ…........
https://www.youtube.com/watch?v=_1ZJ343CYIU
https://www.youtube.com/watch?v=u4JAi2JJhI8
https://www.youtube.com/watch?v=MfXxic8IhkI
https://www.youtube.com/watch?v=Rezetez59Nk
https://www.youtube.com/watch?v=wGXB9OWhPTg
https://www.youtube.com/watch?v=lPAeiLyXwfY
urend into none and the saved left is now the right of the root and the orgiinal right is now joined to the rightmost node in the new right o
r option at date 20/6/22
https://www.youtube.com/watch?v=Knynb5QOSMg
https://www.youtube.com/watch?v=LY5hbvFSJqM
https://www.youtube.com/watch?v=P_Y1dGLcHUU
https://www.youtube.com/watch?v=SXKAD2svfmI
https://www.youtube.com/watch?v=9mEUIdP4ytw
https://www.youtube.com/watch?v=Q0WKzdpR74o
Moving window method
https://www.youtube.com/watch?v=AmlVSNBHzJg
https://www.youtube.com/watch?v=QM0klnvTQzk
https://www.youtube.com/watch?v=fPR4C822JOM
https://www.youtube.com/watch?v=unw9XO7vUYQ&t=47s
https://www.youtube.com/watch?v=tAdMNnd3CII
https://www.youtube.com/watch?v=G8xtZy0fDKg
https://www.youtube.com/watch?v=5WT9o2IzmZU
https://www.youtube.com/watch?v=b4mkk8Fk8fs…........https://www.youtube.com/watch?v=LkrsdWa69_Q
hich is greater in speed will count as a fleet of the car that is the current and rest in front that take more time than it to reach the target.since
n it to reach the target.since we cannot pass and the faster car slow down for slower cars.