Striver's A2Z DSA Sheet

Beginner Problems

  1. Pattern 1
  2. Pattern 2
  3. Pattern 3
  4. Pattern 4
  5. Pattern 5
  6. Pattern 6
  7. Pattern 7
  8. Pattern 8
  9. Pattern 9
  10. Pattern 10
  11. Pattern 11
  12. Pattern 12
  13. Pattern 13
  14. Pattern 14
  15. Pattern 15
  16. Pattern 16
  17. Pattern 17
  18. Pattern 18
  19. Pattern 19
  20. Pattern 20
  21. Pattern 21
  22. Pattern 22
  23. Count all Digits of a Number
  24. Count number of odd digits in a number
  25. Reverse a number
  26. Palindrome Number
  27. Return the Largest Digit in a Number
  28. Factorial of a given number
  29. Check if the Number is Armstrong
  30. Check for Perfect Number
  31. Check for Prime Number
  32. Count of Prime Numbers till N
  33. GCD of Two Numbers
  34. LCM of two numbers
  35. Divisors of a Number
  36. Sum of Array Elements
  37. Count of odd numbers in Array
  38. Check if the Array is Sorted I
  39. Reverse an array
  40. Highest Occurring Element in an Array
  41. Second Highest Occurring Element
  42. Sum of Highest and Lowest Frequency
  43. Reverse a String II
  44. Palindrome Check
  45. Largest Odd Number in a String
  46. Longest Common Prefix
  47. Isomorphic Strings
  48. Rotate String
  49. Valid Anagram
  50. Sort Characters by Frequency
  51. Sum of First N Numbers
  52. Factorial of a Given Number
  53. Sum of Array Elements II
  54. Reverse a String I
  55. Check if String is Palindrome or Not
  56. Check if a Number is Prime or Not
  57. Reverse an array 2
  58. Check if the Array is Sorted II
  59. Sum of Digits in a Given Number
  60. Fibonacci Number

Sorting

  1. Selection Sort
  2. Bubble Sort
  3. Insertion Sorting
  4. Merge Sorting
  5. Quick Sorting

Arrays

  1. Linear Search
  2. Largest Element
  3. Second Largest Element
  4. Maximum Consecutive Ones
  5. Left Rotate Array by One
  6. Left Rotate Array by K Places
  7. Move Zeros to End
  8. Remove duplicates from sorted array
  9. Find missing number
  10. Union of two sorted arrays
  11. Intersection of two sorted arrays
  12. Majority Element-I
  13. Leaders in an Array
  14. Rearrange array elements by sign
  15. Print the matrix in spiral manner
  16. Pascal's Triangle I
  17. Pascal's Triangle II
  18. Pascal's Triangle III
  19. Rotate matrix by 90 degrees
  20. Set Matrix Zeroes
  21. Two Sum
  22. 3 Sum
  23. 4 Sum
  24. Sort an array of 0's 1's and 2's
  25. Kadane's Algorithm
  26. Next Permutation
  27. Majority Element-II
  28. Find the repeating and missing number
  29. Count Inversions
  30. Reverse Pairs
  31. Maximum Product Subarray in an Array
  32. Merge two sorted arrays without extra space

Hashing

  1. Longest Consecutive Sequence in an Array
  2. Longest Subarray with given Sum K (Positives)
  3. Longest Subarray with sum K (Positives + Negatives)
  4. Count Subarrays with given XOR K
  5. Count Subarrays with given sum
  1. Binary Search to find X in sorted array
  2. Lower Bound
  3. Upper Bound
  4. Search insert position
  5. Floor and Ceil in Sorted Array
  6. First and last occurrence
  7. Search in rotated sorted array-I
  8. Search in rotated sorted array-II
  9. Find minimum in Rotated Sorted Array
  10. Find out how many times the array is rotated
  11. Single element in sorted array
  12. Find square root of a number
  13. Find Nth root of a number
  14. Find the smallest divisor
  15. Koko eating bananas
  16. Minimum days to make M bouquets
  17. Capacity to Ship Packages Within D Days
  18. Kth Missing Positive Number
  19. Painter's Partition
  20. Aggressive Cows
  21. Book Allocation Problem
  22. Find peak element
  23. Median of 2 sorted arrays
  24. Kth element of 2 sorted arrays
  25. Minimize Max Distance to Gas Station
  26. Split array - largest sum
  27. Find row with maximum 1's
  28. Search in a 2D Matrix
  29. Search in 2D matrix - II
  30. Find Peak Element - II
  31. Matrix Median

Recursion

  1. Pow(x,n)
  2. Generate Parentheses
  3. Power Set
  4. Check if there exists a subsequence with sum K
  5. Count all subsequences with sum K
  6. Combination Sum
  7. Combination Sum II
  8. Subsets I
  9. Subsets II
  10. Combination Sum III
  11. Letter Combinations of a Phone Number
  12. Palindrome partitioning
  13. Word Search
  14. N Queen
  15. Rat in a Maze
  16. M Coloring Problem
  17. Sudoku Solver

Linked-List

  1. Traversal in Linked List
  2. Deletion of the head of LL
  3. Deletion of the tail of Linked List
  4. Deletion of the Kth element of Linked List
  5. Delete the element with value X
  6. Insertion at the head of Linked List
  7. Insertion at the tail of Linked List
  8. Insertion at the Kth position of Linked List
  9. Insertion before the value X in Linked List
  10. Convert Array to Doubly Linked List
  11. Delete Tail of Doubly Linked List
  12. Delete Kth Element of Doubly Linked List
  13. Removing given node in Doubly Linked List
  14. Insert node before head in Doubly Linked List
  15. Insert node before tail in Doubly Linked List
  16. Insert node before (kth node) in Doubly Linked List
  17. Insert before given node in Doubly Linked List
  18. Add two numbers in Linked List
  19. Segregate odd and even nodes in Linked List
  20. Sort a Linked List of 0's 1's and 2's
  21. Remove Nth node from the back of the LL
  22. Reverse a LL
  23. Add one to a number represented by LL
  24. Find Middle of Linked List
  25. Delete the middle node in LL
  26. Check if LL is palindrome or not
  27. Find the intersection point of Y LL
  28. Detect a loop in LL
  29. Find the starting point in LL
  30. Length of loop in LL
  31. Reverse a Doubly Linked List
  32. Find pairs with given sum in DLL
  33. Remove duplicates from sorted DLL
  34. Delete all occurrences of a key in DLL
  35. Flattening of a Linked List
  36. Clone a Linked List with random and next pointer
  37. Sort a LL
  38. Delete Node in a Linked List
  39. Rotate a LL

Bit Manipulation

  1. Introduction to Bit Manipulation
  2. Check if the i-th bit is set or not
  3. Check if a number is odd or not
  4. Check if a number is power of 2 or not
  5. Count the number of set bits
  6. Set/Unset the rightmost unset bit
  7. Swap two numbers

Greedy Algorithms

  1. Assign Cookies
  2. Fractional Knapsack
  3. Greedy algorithm to find minimum number of coins
  4. Lemonade Change
  5. Valid Parenthesis String
  6. N meetings in one room
  7. Jump Game
  8. Jump Game II
  9. Minimum number of platforms required for a railway
  10. Job sequencing Problem
  11. Candy
  12. Program for Shortest Job First (SJF) CPU Scheduling
  13. Program for Least Recently Used (LRU) Page Replacement Algorithm
  14. Insert Interval

Sliding Window / 2 Pointer

  1. Longest Substring Without Repeating Characters
  2. Max Consecutive Ones III
  3. Fruit Into Baskets
  4. Longest Repeating Character Replacement
  5. Binary Subarrays With Sum
  6. Count Number of Nice Subarrays
  7. Number of Substrings Containing All Three Characters
  8. Maximum Points You Can Obtain from Cards
  9. Longest Substring with At Most K Distinct Characters
  10. Subarray with k different integers
  11. Minimum Window Substring

Stack / Queues

  1. Implement Stack using Arrays
  2. Implement Queue using Arrays
  3. Implement Stack using Queue
  4. Implement Queue using Stack
  5. Implement stack using Linkedlist
  6. Implement queue using Linkedlist
  7. Check for balanced parentheses
  8. Implement Min Stack
  9. Infix to Postfix Conversion using Stack
  10. Prefix to Infix Conversion
  11. Prefix to Postfix Conversion
  12. Postfix to Prefix Conversion
  13. Postfix to Infix
  14. Infix to Prefix Conversion
  15. Next Greater Element
  16. Next Greater Element II
  17. Next Smaller Element
  18. Number of NGEs to the right
  19. Trapping Rainwater
  20. Sum of subarray minimum
  21. Asteroid Collision
  22. Sum of subarray ranges

Binary Trees

  1. Introduction to Trees
  2. Binary Tree Representation in C++
  3. Binary Tree Representation in Java
  4. Binary Tree Traversals in Binary Tree
  5. Preorder Traversal of Binary Tree
  6. Inorder Traversal of Binary Tree
  7. Postorder Traversal of Binary Tree
  8. Level order Traversal / Level order traversal in spiral form
  9. Iterative Preorder Traversal of Binary Tree
  10. Iterative Inorder Traversal of Binary Tree
  11. Postorder Traversal of Binary Tree using 2 stack
  12. Postorder Traversal of Binary Tree using 1 stack
  13. Preorder, Inorder, and Postorder Traversal in one Traversal
  14. Height of a Binary Tree
  15. Check if the Binary tree is height-balanced or not
  16. Diameter of Binary Tree
  17. Maximum Path Sum
  18. Check if two trees are identical or not
  19. Zig Zag Traversal of Binary Tree
  20. Boundary Traversal of Binary Tree
  21. Vertical Order Traversal of Binary Tree
  22. Top View of Binary Tree
  23. Bottom View of Binary Tree
  24. Right/Left View of Binary Tree
  25. Symmetric Binary Tree
  26. Root to Node Path in Binary Tree
  27. LCA in Binary Tree
  28. Maximum Width of Binary Tree
  29. Check for Children Sum Property
  30. Print all the Nodes at a distance of K in Binary Tree
  31. Count total Nodes in a Complete Binary Tree

Binary Search Trees

  1. Introduction to Binary Search Tree
  2. Search in a Binary Search Tree
  3. Find Min/Max in BST
  4. Ceil in a Binary Search Tree
  5. Floor in a Binary Search Tree
  6. Insert a given Node in Binary Search Tree
  7. Delete a Node in Binary Search Tree
  8. Find K-th smallest/largest element in BST
  9. Check if a tree is a BST or not
  10. LCA in Binary Search Tree
  11. Construct a BST from a preorder traversal
  12. Inorder Successor/Predecessor in BST
  13. Merge 2 BST's
  14. Two Sum In BST
  15. Recover BST
  16. Largest BST in Binary Tree

Heaps

  1. Introduction to Priority Queues using Binary Heaps
  2. Min Heap and Max Heap Implementation
  3. Check if an array represents a min-heap or not
  4. Convert min Heap to max Heap
  5. Kth largest element in an array
  6. Kth smallest element in an array
  7. Sort K sorted array
  8. Merge M sorted Lists
  9. Replace each array element by its corresponding rank

Graphs

  1. Graph and Types
  2. Graph Representation
  3. Connected Components
  4. BFS
  5. DFS
  6. Number of provinces
  7. Connected Components Problem in Matrix
  8. Rotten Oranges
  9. Flood fill
  10. Cycle Detection in Undirected Graph (BFS)
  11. Cycle Detection in Undirected Graph (DFS)
  12. 0/1 Matrix (Bfs Problem)
  13. Surrounded Regions
  14. Number of Enclaves
  15. Word ladder - 1
  16. Word ladder - 2
  17. Number of Distinct Islands
  18. Bipartite Graph (BFS)
  19. Bipartite Graph (DFS)
  20. Cycle Detection in Directed Graph (DFS)
  21. Topo Sort
  22. Kahn's Algorithm
  23. Cycle Detection in Directed Graph (BFS)
  24. Course Schedule - I
  25. Course Schedule - II
  26. Find Eventual Safe States
  27. Alien Dictionary
  28. Shortest Path in UG with unit weights
  29. Shortest Path in DAG
  30. Dijkstra's Algorithm
  31. Floyd warshall algorithm
  32. Find the city with the smallest number of neighbors
  33. Disjoint Set
  34. Find the MST weight
  35. Number of operations to make network connected
  36. Accounts merge
  37. Number of islands II
  38. Making a large island
  39. Most stones removed with same row or column
  40. Kosaraju's algorithm
  41. Bridges in graph
  42. Articulation point in graph

Dynamic Programming

  1. Climbing stairs
  2. Frog Jump
  3. Frog jump with K distances
  4. Maximum sum of non adjacent elements
  5. House robber
  6. Ninja's training
  7. Grid unique paths
  8. Unique paths II
  9. Minimum Falling Path Sum
  10. Triangle
  11. Cherry pickup II
  12. Best time to buy and sell stock
  13. Best time to buy and sell stock II
  14. Best time to buy and sell stock III
  15. Best time to buy and sell stock IV
  16. Best time to buy and sell stock with transaction fees
  17. Subset sum equals to target
  18. Partition equal subset sum
  19. Partition a set into two subsets with minimum absolute sum difference
  20. Count subsets with sum K
  21. Count partitions with given difference
  22. 0 and 1 Knapsack
  23. Minimum coins
  24. Target sum
  25. Coin change II
  26. Unbounded knapsack
  27. Rod cutting problem
  28. Longest Increasing Subsequence
  29. Print Longest Increasing Subsequence
  30. Largest Divisible Subset
  31. Longest String Chain
  32. Longest Bitonic Subsequence
  33. Number of Longest Increasing Subsequences
  34. Longest common subsequence
  35. Longest common substring
  36. Longest palindromic subsequence
  37. Minimum insertions to make string palindrome
  38. Minimum insertions or deletions to convert string A to B
  39. Shortest common supersequence
  40. Distinct subsequences
  41. Edit distance
  42. Wildcard matching
  43. Matrix chain multiplication
  44. Burst balloons
  45. Palindrome partitioning II
  46. Partition Array for Maximum Sum
  47. Different Ways to Evaluate a Boolean Expression

Tries

  1. Trie Implementation and Operations
  2. Trie Implementation and Advanced Operations
  3. Longest Word with All Prefixes
  4. Number of distinct substrings in a string
  5. Maximum XOR of two numbers in an array
  6. Maximum Xor with an element from an array

Strings (Advanced Algo)

  1. Reverse every word in a string
  2. Minimum number of bracket reversals to make an expression balanced
  3. Count and say
  4. Rabin Karp Algorithm
  5. Z function
  6. KMP Algorithm or LPS array
  7. Shortest Palindrome
  8. Longest happy prefix

Maths

  1. Print all primes till N
  2. Prime factorisation of a Number
  3. Count primes in range L to R

SOURCE: takeuforward

Archive

More
Stories.

Back To Stories