90 Days Roadmap: Dsa Sheet

Download as pdf or txt
Download as pdf or txt
You are on page 1of 30

DSA SHEET

by
Prashant Kumar
90 Days Roadmap

1
ARRAYS

 Understand Big O notation (Time


and Space complexity)

 Complexity problems to optimized  Study Searching and Sorting


solution (e.g.- O(n2) -> O(n)…) algorithms thoroughly.

 Quick and Merge Sort is must to have

 Element search in sorted array

 Find smallest letter greater than


target

 Search in Rotated Sorted Array


 Basic Concepts of Array like Insertion,
Deletion and Searching in array.  Merge Sorted array in both orders

 Two pointer approach to solve the array  Sort Colors


problems.
 Wiggle Sort
 Rotate array problem with K steps 

 Kadane’s Algo to find Max Subarray

 Two Sum Problem

 Buy and Sell Stocks

 Searching in 2D Matrix/Array

 Search Matrix Zeros

 Pascals Triangle
 Understand recursion. Binary Search
 Spiral Matrix 1 and 2
is must to implement with it.
 Set matrix Zeroes
 Factorial of a number
 Rotate Image problem
 Fibonacci number with optimization.
 Unique Paths 1 and 2
 Length of String using recursion.


2
ARRAYS

 Next Permutations  XOR queries of a subarray.

 Word Search  Maximum Points you can obtain from


cards
 Longest Consecutive Sequence in
unsorted array  First Missing Positive

 3 Sum Problem  Trapping Rain Water Problem

 4 Sum Problem  Product of array except self

 Container with most water

 Insert Delete get Random- O(1)

 Game of Life

 Max Area of Island  Pow(x, n)

 Find all possible Subsets  Majority Element 1

 Best Time to Buy and Sell Stock 2  Majority Element 2

 Best Time to Buy and Sell Stock 3  Reverse Pairs

 Maximum Profit from Trading Stocks  Island Perimeter


problem
 Flood Fill

 Coloring a border

3
LINKED LIST

 What is LinkedList? How its


different form array and ArrayList?
 Swap Nodes in Pairs
 When will you choose LinkedList?
 Rotate a given LinkedList
 Try to design your own LinkedList
with all its major properties like  Remove duplicate elements from sorted
a. Insertion LinkedList
b. Deletion
c. LinkedList Traversal  Swap node in the LinkedList without
d. Searching a Node swapping the data

 Time and Space complexity for each  Move Last element to first position in
operation given LinkedList

 Find the length of the LinkedList


 Merge K-sorted LinkedList
 Nth Node of The LinkedList
 Reverse LinkedList Nodes In given K -
 Middle of a given LinkedList group

 Detect the cycle in LinkedList  Subtraction in LinkedList

 Reverse a LinkedList  Clone a LinkedList with Next and


Random Pointer
 Palindrome of LinkedList

 Intersection of Two LinkedList

4
LINKED LIST

 Introduction of Doubly LinkedList

 Advantages/Disadvantages of Doubly
LinkedList over Singly LinkedList

 Try to design your own Doubly


LinkedList with all its major
properties like
a. Insertion
b. Deletion
c. Traversal
d. Searching a Node

 LRU Cache

 Flatten a multilevel Doubly LinkedList

 Design a Browser History

 Introduction to Circular LinkedList

 Implementation of Circular LinkedList


with its major features.

 Check if a LinkedList is a Circular


LinkedList

 Convert Singly LinkedList in to Circular
LinkedList

 Count Nodes in Circular LinkedList

 Check if two Circular LinkedList are


identical

5
RECURSION

 What is recursion? And how does it  Tower of Hanoi


make coding simplified?
 Combination Sum 1
 Understand the features around
which recursion revolves  Combination Sum 2
a. Base Case
b. How to define Base case  Recursive function to delete the Kth
c. Recursive calls node of the LinkedList

 What is Recursion Tree and how does  Find middle of the LinkedList
it work internally on memory level. recursively

 Fundamentals of Tail Recursion with  Reverse a doubly LinkedList


will tail call elimination for
optimization of solutions.

 Print all combination of factors of a


given number
 Fibonacci Number
 Flood Fill
 Check if a given number is palindrome or
not?  Word Search

 Pascal Triangle  N-Queens Problem

 Permutations  Reverse Nodes in K-Group

 Permutation Sequence

6
STACK

 Introduction to Stack in Data-Structures


with its representations.

 Understand the basic operations of Stack


a. PUSH Operation
b. POP Operation
c. PEEK Operation
d. isFull()
e. isEmpty()

 Implementation of Stack using Arrays

 Implementation of Stack using Singly


LinkedList

 Min Stack
 Restrictive Candy Crush
 Valid Parentheses
 LRU Cache (Most Important)
 Convert Infix to Postfix expression
 Tweets Count per frequency
 Convert Prefix to Postfix expression
 Largest Rectangular area in
 The Stock Span Problem Histogram

 Daily Temperature  Implementation of LFU cache

 Next Greater Element  Find the maximum of minimum for


every window size in an array

7
QUEUE

 Understand the QUEUE Data Structure

 Understand the basic operations of QUEUE

a. ENQUEUE Operation
b. DEQUEUE Operation
c. PEEK Operation
d. isFull()
e. isEmpty()

 Implementation of QUEUE using Arrays

 Implementation of Stack using Singly


LinkedList

 Implementation of QUEUE using STACK

 First Negative Integer in every window  Reversing first K element of a


of size K QUEUE

 Valid Substring  Sorting QUEUE without extra Space

 Maximum Diamonds  Sliding Window maximum

 Implementation of QUEUE using  Stamping the Sequence


LinkedList
 Minimum Time required to rot all
oranges

8
QUEUE

 Understand Double Ended Queue


(Deque)

 Understand the various operations of


Deque Data Structures
a. Insertfront()
b. InsertLast()
c. Deletefront()
d. DeleteLast()

 Understand the Circular Queue

 Try out various circular queue


operations like Front, Rear.

 Design Circular Deque

 Design Circular Queue

 Design Front Middle Back Queue

 Implementation of Deque using doubly


LinkedList

 Find the Celebrity

9
PRIORITY QUEUE(HEAP)

 Understand the concept of Priority


Queue DataStructure

 Understand the difference between


Normal Queue and Priority queue

 Understand the various operations of


Priority Queue Data Structures
a. INSERTION
b. DELETION
c. PEEK  K-Closest points to origin
d. POLL
 Kth Largest Element in an Array
 Implementation of priority Queue
using Array  Maximum Product of two elements in an
Array

 Relative Ranks

 Top K frequent Elements

 Adding Array Elements

 Minimum Cost of Ropes

 Binary Heap Operations

10
HASHING

 Understand the Hashing and why it is


used exactly?

 What is HashCode and how does it


get generated?  Key Pairs

 Understand the types of Hashing in  Top K frequent elements in an Array


Data Structure.
 Intersection of Two Arrays
 What is Hash Function and user
defined Hash Functions  Design HashMap with its Operations

 Understand Index mapping (Trivial  Design HashSet with its Operations


Hashing)
 Find an array is subset of another
array

 What is HashTable and its applications.

 Implement database indexes.  Repeated DNA sequence

 Encode & Decode Tiny URL


 Used to implement associative arrays.
 Check if two Arrays are equal or not
 Role of HashTable in designing HashMap
and HashSet  Count pairs with given Sum

 Double Hashing and its uses  Find all triplet with Sum zero

 Internal Mappings of HashMap/HashSet  Longest subarray with sum divisible


by K
 Methods of HashMap/HashSet

11
BINARY SEARCH

 Implementation of Binary Search

 Search Insert Position

 Intersection of Two Arrays

 Peak Index In a Mountain Array

 Pow (X, N)

 Minimum Limits of Balls in a Bag

 Median of Two Sorted Arrays

 Count of Smaller Number After Self

 Split Array Largest Sum

 Swim In Rising Water

 Shortest Array With Sum At least K

 Count Of Range Sum

 Intersection of Two Arrays 2  Max Sum of Rectangle No Larger Than


K
 Find Smallest Letter Greater Than
Target

 Search In a Sorted Array

 Search a 2-D Matrix

 Find the Peak Element

 Minimum Size Subarray Sum

 Kth Smallest Element in a Sorted


Matrix

12
TREES

 Invert Binary Tree


 Understand the Binary Tree
DataStructure with its types
 Binary Tree Paths
 Design Binary tree with Nodes and
 Binary Tree Path Sum
perform its operations
a. Insertion
 Sub Tree of Another Tree
b. Deletion
c. Searching
 Average of levels in Binary Tree
 In-Order Tree Traversal
 Evaluate Boolean Binary Tree
 Pre-Order Tree Traversal
 Sum of Left Leaves of given Binary
Tree
 Post-Order Tree Traversal

 Level-Order Traversal (with QUEUE)

 Flatten Binary Tree to Linked List

 Maximum Depth of Binary Tree  Binary Tree Right Side View

 Symmetric Tree  Left View of a Binary Tree

 Zig-Zag Level Order Tree Traversal  Top View of Binary Tree

 Balance Binary Tree  Height of a Binary Tree

 Diameter of Binary Tree  Bottom View of Binary Tree

 Sum Tree

13
TREES

 Understand the Binary Search Tree


DataStructure

 Convert Sorted Array to BST

 Search a Node in BST

 Insert a Node in BST

 Delete a Node from BST


 Lowest Common Ancestor of a Binary
Tree  Construct BST from Post-Order
Traversal
 Path Sum 2
 Minimum Absolute Difference in BST
 Find Largest Value in Each Tree Row

 Binary Tree Maximum Path Sum

 Vertical Order Traversal of a Binary


Tree

 Validate Binary Search Tree

 Kth Largest Element in BST

 Predecessor And Successor

 Unique Binary Search Trees

 Unique Binary Search Trees 2

 Convert Sorted List to Binary Search


Tree

14
TREES

 Binary Search Tree Iterator

 Serialize and Deserialize a Binary


Search Tree

 Balance a Binary Search Tree

 Remove BST keys outside of the given


range
 Merge Two BSTs
 Binary Tree Cameras
 Kth Smallest Element in BST
 Number of ways to reorder to get a
 Maximum Sum BST in Binary Tree Binary Search Tree

 Ceil in BST

 Find Common Nodes in Two BSTs

 Sum of Leaf Nodes in Binary Search


Tree

 AVL Tree Insertion

 Optimal Binary Search Tree

 Merge BSTs to create single Binary


Search Tree

 Find Shortest Range in Binary Search


Tree

15
MATH

 SQRT(X)  Rearrange an Array with an O(1) extra


Space
 Palindrome Number
 Integer Break
 Happy Number
 Power of 2 and Subsequences
 Power of Two
 Shuffle an Array
 Maximum Product of Given Three
Numbers  Brain Game

 Is Binary Number Multiple of 3

 Dice Throw

 Minimum Moves to Equal an Array


Elements
 Max Points on a Line
 Arranging Coins
 Permutation Sequence
 Multiply Strings
 Number of Digit One
 Valid Squares
 Count the subarrays having product
 Basic Calculator 2 less than K

 Count Numbers with Unique Digits  Return Two Prime Numbers

 Poor Pigs

16
BIT MANIPULATION

 Count Total Set Bits  Find the Duplicate Number

 Maximum AND Value  Josephus Problem

 Missing Number in an Array  Maximum XOR of two numbers in an


Array
 Reverse Bits
 Division without using multiplication,
 Number of 1 Bits division and MOD operator

 Sum of Bit Difference

 Cinema seat Allocation

 Gray Code 2

 Construct a list using given q XOR


queries

 Bleak Numbers

17
GRAPH

 Understand GRAPH DataStructure  Course Schedule (BFS)

 Understand Graph Representation  Course Schedule (DFS)


a. Adjacency Matrix
b. Adjacency List  Topological Sort (BFS)

 Understand both type of Graph  Topological Sort (DFS)


a. Directed Graph
b. Undirected Graph  Find the total number of Islands
present
 Understand Connected component
Graph

 Difference between Tree and Graph


and its uses

 Understand and Implement Dijkstra


Algorithm

 Cheap Flights within K stops

 Understand and Implement BFS of  Understand and implement the Floyd


Graph Warshall Algorithm

 Understand and Implement DFS of  Understand and Implement Bellman


Graph Ford Algorithm

 Possible Paths between Two Vertices  Reverse Pairs

 Sum of Dependencies in a Graph  Island Perimeter

18
GRAPH

 Numbers of Closed Islands


 Understand the concept of Spanning
Tree and Minimum Spanning Tree
 Find the City with Smallest Number of
Neighbors at a Threshold Distance
 Read the two most important
algorithms of Minimum Spanning tree
 Possible Bipartition
a. Prims Algorithm
b. Kruskal Algorithm  Find Eventual Safe States
 Implement Minimum Spanning Tree
 Is Graph Bipartite?
 Min Cost to Connect all the Points  Minimum Jumps to Reach Home

 Bridge Edge in a Graph

 Flood Fill Algorithm


 Johnsons Algorithm (All Pairs Shortest
Path)
 Clone Graph
 Mother Vertex
 Course Schedule
 Count the paths
 Course Schedule 2
 Eulerian Path in an Undirected Graph
 Word Ladder
 Strongly Connected Components
 Word Ladder 2
(Kosaraju’s Algorithm)
 Time needed to inform all employee

19
GRAPH

 Minimum number of vertices to reach


all Nodes

 Number of Provinces

 Snake and Ladder Problem

 Critical Connections

 Reachable Nodes in Subdivided Graph

 Sum of Distance in a Tree

 Cracking the Safe

 Parallel Course 3

 Cheapest Flight with K Stops

 Number of ways to arrive at given


Destination

20
GREEDY

 Understand the concepts of Greedy


Algorithms and its significance

 Implement the Greedy Algorithms


like
a. Knapsack Problem
b. Huffman Coding
c. Ford-Fulkerson
Algorithm

 Remove K- Digits

 Non-Overlapping Intervals

 Candy

 Minimum Number of taps to open to


water a garden

 Minimize the heights 2


 Number of Coins
 Jump Game
 Job Sequencing Problem
 Water Connection Problem
 Partition Labels

 Balance a Binary Search Tree

 Reduce Array Size to the Half

 Maximum Total Importance of Road

21
NUMBER THEORY

 Ugly Number 3

 Simplified Fractions

 Number of pairs of interchangeable


rectangles

 Minimum Lines to represent a Line


Chart

 Largest sum of Digits in all Divisor

 Add Digits  Find Unit Digit in a Product

 X of a Kind in a deck of cards

 Find Greatest Common Divisor of an


Array

 Remainder of Array Multiplication

 Sum of K Primes

 Check if it is a good Array

 Count ways to make Array with


Product

 Replace non-Coprime Numbers in an


Array

 Minimum deletion to make Array


Divisible

22
DYNAMIC PROGRAMMING

 Understand the fundamentals of  Get Maximum in Generated Array


Dynamic Programming
 Is Subsequence?
 Recursion vs Dynamic Programming
 Stickler Thief
 Understand the Overlapping
Subproblem in DP solution  Longest Repeating Subsequence

 Tabulation vs Memorization  Activity Selection

 Fibonacci Number

 Pascal’s Triangle

 Count Number of Hops

 Minimum Falling Path Sum


 Counting Bits
 Where will the Ball Fall
 Climbing Stairs
 Arithmetic Slices
 Nth Fibonacci Number
 Beautiful Arrangement
 Gold Mine Problem
 Best Time to Buy and Sell Stocks 2
 Best Time to Buy and Sell Stock
 Unique Paths
 Pascals Triangle 2

23
DYNAMIC PROGRAMMING

 Box Stacking

 Wildcard Pattern Matching

 Player with Max Score

 Count All Possible paths from Top


Left to Bottom Right

 Maximize Dot Product

 Maximum Product Subarray

 Longest Common Subsequence

 Coin Change 2

 Best Sightseeing Pair

 Best Time to Buy and Sell Stock with


Cooldown

 Shopping Offers
 Count of Strings that can be formed
using a, b and c under given constraint  Integer Break

 Maximal Square

 Delete and Earn

 Knight Dialer

 Palindromic Substring

 Word Break

24
DYNAMIC PROGRAMMING

 Tapping Rain Water

 Edit Distance

 Best Time to Buy and Sell Stock 4

 01 Matrix  Stone Game 4

 Ugly Number 2  Burst Balloons

 Matrix Chain Multiplication  Minimum Cost to cut a Stick

 Partition Equal Subset Sum  Minimum Difficulty of a Job Schedule

 Boolean Parenthesization

 Super Egg Drop

 Shortest Path Visiting all Nodes

 Longest Increasing Path ins a Matrix

 Distinct Subsequences

 Regular Expression Matching

 Longest Valid Parentheses

25
STRINGS

 Multiply Two Strings  Longest K Unique Characters Substring

 Reverse Words in given String  Number of Matching Subsequence

 Group Anagrams  Letter Combination of a Phone Number

 Integer To Roman  Top K Frequent Words

 Implement Trie (Prefix Tree)  Word Subsets

 Decode String

 Find All Anagram in a String

 Minimum Remove to make valid


Parentheses
 Permutations of a given String
 Simplify Path
 Largest Number in K Swaps
 Longest Common Prefix in an Array
 Longest Substring without Repeating
 Longest Prefix Suffix Characters

 Implement Atoi  Reverse Each Words in a Given String

 Length of Longest Substring  Add Binary Strings

 Number Following a Pattern

26
STRINGS

 Number with One Absolute


Difference

 Distinct Palindromic Substrings

 Similar String Group

 Minimum Window Substring

 Count And Say

 Find all Possible Palindromic Partition


of a String

 Number of distinct word with K


maximum contiguous Vowels

 Substring with Concatenation of All


Words

 Valid Number

 Text Justification

27
BACKTRACKING

 Binary Tree Paths

 Permutations 2

 Combination

 Combination Sum 2

 Letter Case Permutation

 Split a String into Max Number of


Unique Substrings

 N-Queens 2

 Sudoku Solver

 Rat in a Maze Problem 1

 Largest Number in K Swaps

 Generate Parentheses

28
MISC ALGORITHMS

 Counting Sort

 Heap Sort

 Search Pattern (Rabin-Karp


Algorithm)

 Pair with given Sum in Sorted Array

 Search Pattern (Z-Algorithm)

 Search Pattern (KMP Algorithm)

 Floyd Cycle Detection Algorithm

 Euclid’s Algorithm

 Union Find Algorithm

 Moore’s Algorithm

 Insert Delete get Random- O(1)

29
https://www.linkedin.com/in/prashant-kumar-76b786168/

https://github.com/prashantt17

@prashantkumar

30

You might also like