“Keep showing up. That's where the magic happens.”
— GrindGram
View full list(413 problems)

Basics· 12

  • Find even or odd
  • Count digits in a number
  • Reverse a number
  • Prime number
  • Armstrong number
  • Check palindrome of number
  • Square root of a number
  • Find last digit in a number
  • Find power of a number
  • GCD
  • Print all divisors of a number
  • Perfect number

Array - Data structure· 31

Basics with traversal

  • Find the maximum and minimum element in array
  • Sort an array of 0s , 1s and 2s
  • Check if two arrays are equal or not
  • Array subset of another array
  • What is an array? How is it represented?
  • Find third largest element in array
  • Find missing number in array
  • Find repeating number in array
  • Rotate the array by 1
  • Search an element in array
  • Count frequency of elements in array
  • Rotate the array by k
  • Learn what is map and how its represented before moving forward

Two pointer

  • Union of two arrays
  • Remove duplicates from array
  • kth element of 2 sorted arrays
  • Find pair with given sum
  • 3 Sum
  • 4 Sum
  • Find triplets with zero sum
  • Find count of triplets
  • Intersection of two arrays
  • Length of longest subarray with sum k
  • Trapping rain water

Advanced Problems

  • Majority element
  • Count inversions
  • Merge intervals
  • Kadane's algo (super imp)
  • Maximum product subarray
  • Next permutation
  • Seive of eratosthenes (Popular algo for prime numbers)

Time and Space Complexity

Matrix - Data structure· 7

  • Maximum num of 1's row
  • Left rotate matrix k times
  • What is a 2D Array? How to access element?
  • Search in a matrix
  • Rotate by 90 degree
  • Print matrix in diagonal pattern
  • Set matrix zeros

Binary Search - Algorithm· 28

Basic pattern

  • Find floor and ceil in sorted array
  • Find first and last occurrence of element in sorted array
  • Find missing num from 1 to N
  • Find square root
  • Search for element in infinite array
  • Search in a sorted array

Sorted rotated array

  • Search element in sorted rotated array
  • Number of times array is sorted
  • Minimum element in sorted rotated array
  • Maximum element in sorted rotated array

Biotonic array

  • Find the peak element
  • Search element in biotonic array

Matrix

  • Find row with maximum number of 1s
  • Search in row wise column wise sorted matrix
  • Search in sorted matrix II
  • Find peak in sorted matrix

Application(Super imp)

  • Allocate minimum pages
  • Painter partition
  • Split array largest sum
  • Minimum num of days to make m bouquets
  • Capacity to ship packages within D days
  • koko eating bananas
  • kth smallest number in matrix multiplication table
  • kth smallest pair distance
  • Ugly number II
  • Median of 2 sorted arrays
  • Find smallest divisor given threshold
  • Aggressive cows

Sorting - Algorithm· 5

  • Selection sort
  • Insertion sort
  • Merge sort
  • Quick sort
  • Bubble sort

Linked List - Data structure· 35

Basic patterns

  • Union and Intersection of LL
  • Delete without head pointer
  • Create, Insert, Delete Operations in LL
  • Search for an element in LL
  • Reverse a LL
  • Check if LL is a Palindrome
  • Middle element of LL
  • Find the intersection point of Y LL
  • Count pairs with given sum
  • Reverse LL in groups of given size

Loop

  • Find length of loop in LL
  • Find the starting point of loop
  • Remove the loop
  • Detect loop in LL

Sorting, Merging & Related

  • Sort 0s, 1s, 2s in LL
  • Pairwise swap elements
  • Merge sort in LL
  • Quick sort in LL
  • Remove occurrence of duplicates in sorted & unsorted LL
  • Seggregate even and odd nodes in LL
  • Merge k sorted LL

Arithmetic(Reversal & traversal - Once you learnt these, you can solve probs in this pattern)

  • Add 2 numbers represented as LL
  • Add 1 to a number represented as LL
  • Subtraction on LL

Must solve other probs(Try to solve these probs on own, brute force atleast you can come up for most of them after solving above)

  • Learn the basics of circular LL
  • Rotate LL
  • Delete nodes having greater value on right
  • Delete N nodes after M nodes
  • Clone a LL
  • Length of longest palindrome in LL
  • Flattening a LL
  • Delete all occurrence of node

Double Linked List

  • Insert, Delete, Reverse DLL
  • Pairs with given sum in DLL
  • Learn the basic representation of the nodes in LL

Stack - Data structure· 22

Basic

  • Implement 2 stack using array
  • Check for balanced parenthesis
  • What is stack? Learn how to represent the data structure and working of it
  • Get min from stack in O(1) space and time

Next greater element

  • Next greater element
  • Next greater element II

Next smallest element(Once above pattern is covered, try to solve this on own)

  • Next smallest element on left
  • Next smallest element on right
  • Trapping rainwater
  • Stock span problem
  • Maximum rectangular area on histogram
  • Max rectangle

Expressions

  • Infix to postfix
  • Evaluation of postfix expression
  • Prefix to postfix
  • Arithmetic expression evaluation

Reversing stack

  • Insert at bottom of stack
  • Reverse a stack
  • Sort stack

Implementation probs

  • Celebrity problem
  • Restrictive candy crush
  • Count the reversals

Queue - Data structure· 11

Basic pattern

  • What is queue? Learn the basic representation and how its implemented?
  • Implement queue using stack(super imp)
  • Implement stack using queue(super imp)
  • Implement queue using linkedlist
  • Reverse a queue

Implementation probs

  • Circular tour
  • First non repeating char in stream
  • Reverse first k elements in queue
  • LRU Cache(super imp)
  • Nearly sorted
  • Minimum cost of ropes

Tree - Data structure· 56

Traversals

  • PreOrder Traversal
  • InOrder Traversal
  • PostOrder Traversal
  • Level Order Traversal
  • Understand the basic of how tree data structure is represented
  • Boundary Traversal
  • Vertical Traversal
  • Top View of BT
  • Bottom View of BT
  • Left View of BT
  • Right View of BT
  • Diagonal Traversal

Basic and Easy patterns(Try to solve these once you learnt traversals)

  • Height of the tree
  • Diameter of the tree
  • Check if 2 trees are identical
  • Check if subtree
  • Check for balanced tree
  • Lowest common Ancestor in BT
  • Symmetric tree
  • Mirror of a tree
  • Check if isomorphic
  • Insert node in a tree
  • Sum tree

Path and Distance

  • Root to leaf paths
  • Nodes at given distance
  • Root to leaf path sum
  • Maximum path sum from any node
  • K Sum Paths
  • Range sum of BST
  • Minimum distance between 2 nodes
  • Maximum distance between node and ancestor
  • Min time to burn a tree

Binary Search Tree

  • Understand what BST is?
  • Insert a node in BST
  • Count BST nodes in the given range
  • Lowest Common Ancestor in BST
  • Inorder successor and predecessor
  • BST to greater sum tree
  • Delete given node from BST
  • Search a value in BST
  • Find minimum and maximum in BST
  • Find the Kth largest element/kth Smallest in BST
  • Check for BST
  • Find the closest element in BST
  • Largest BST in BT
  • Merge two BST
  • Populate inorder successor for all nodes

Construct from given

  • Construct Binary Tree from Preorder and Inorder Traversal
  • Construct BT from parent array
  • Construct Binary Tree from Inorder and Postorder Traversal
  • Construct BST from given preorder traversal

Subtree & Other must do tree probs

  • Serialize and deserialize BT
  • Maximum sum of non adjacent nodes
  • Duplicate subtree
  • Flatten BT to linked list
  • Largest subtree sum in a tree

Sliding Window - Technique· 23

Fixed Sliding Window

  • Maximum sum subarray of size k
  • Maximum of all subarray of size k
  • Count substring of length k with k-1 distinct elements
  • Maximum of minimum for every window
  • Count distinct element in every window
  • First negative integer in every window of size k

Variable Sliding Window

  • Subarray with given sum
  • Subarray with 0 sum
  • Smallest window of distinct elements
  • Smallest window containing 0,1,2
  • Smallest window in string containing all chars of another string
  • Length of longest substring
  • Largest subarray of 0s and 1s
  • Count of anagram occurrence
  • Max consecutive ones III
  • Count number of nice subarrays
  • Longest repeating char replacement
  • Minimum window substring
  • Subarray with k diff integers
  • Longest subarray with given sum k
  • Fruit into basket
  • Minimum window subsequence
  • Sliding window median

Graph - Data structure· 25

Traversals & Basic

  • Understand how graph is represented?
  • Detect cycle in Directed graph
  • Detect cycle in Undirected graph
  • BFS Traversal
  • DFS Traversal
  • Detect Negative cycle in graph

Connected component(After traversal, this will be easy to solve)

  • Number of Islands
  • Number of distinct island
  • Number of closed island
  • Connected component
  • Number of Provinces

Bipartite

  • Bipartite graph
  • M-colouring

Shortest Path

  • Find shortest path in DAG
  • Djikstra Algo
  • Step by Knight
  • Find if path exists
  • Minimum cost path
  • Word ladder I
  • Word ladder II
  • Floyd warshal algo
  • Find shortest path in UG
  • Shortest path source to destiny
  • Covid spread
  • Bellmanford algo

Backtracking & Recursion advanced - Technique· 25

  • Possible words from phone digits
  • Subsets
  • Permutation with spaces
  • Generate parantheses
  • Generate IP address
  • Solve the sudoku
  • kth permutation
  • Word search
  • Palindrome partition of string
  • Decode the string
  • Letter case permutation
  • sum string
  • word boggle
  • Largest number in k swaps
  • Partition array to k subsets
  • Understand the basics of backtracking and start solving
  • Permutation II
  • Permutations of a string
  • Combination sum I
  • Combination sum II
  • Combination sum III
  • Rat in maze
  • Unique subset
  • N-Queen
  • N Queen II

Greedy - Technique· 23

  • Minimum number of jumps
  • Activity selection prob
  • N meetings in a room
  • Minimum platforms
  • Job sequencing prob
  • Fractional knapsack
  • Jump game
  • Insert interval
  • Minimum cost of ropes
  • Valid parantheses - Minimum
  • Least recently used
  • Non overlapping interval
  • Minimum operations
  • Minimize the sum of product
  • Largest number possible
  • Lemonade change
  • Minimize the height
  • Minimum number of coins using greedy
  • Merge interval
  • Partition labels
  • Cinema seat allocation
  • Max length chain
  • Shortest job first

Dynamic Programming· 65

Basic

  • Understand the basics!!

1D - Linear DP

  • Count way to reach nth stair
  • Count way to reach nth stair
  • House robber II
  • Count num of hops
  • House robber

2D Grid DP

  • Count paths - grid
  • Unique paths II
  • Minimum path sum in grid
  • Minimum path sum in triangular grid
  • Minimum/Maximum falling path sum
  • Count all possible paths with condition
  • Max path sum
  • Number of paths with k coins
  • Minimum falling path sum II

DP on subsequence

  • Coin change
  • Min number of coins
  • Rod cutting
  • Target sum
  • Knapsack with duplication items
  • Partition equal subset sum
  • Minimum cost to fill given weight in bag
  • Subset sum problem
  • Count subset with given sum k
  • Minimum sum partition
  • Count partition with given diff
  • 0-1 Knapsack
  • Maximum non adjacent subsequence

DP on Increasing subsequence

  • Longest increasing subsequence
  • Print longest increasing subsequence
  • Longest string chain
  • Num of longest increasing subsequence
  • Longest bitonic subsequence
  • Longest divisible subset

DP on strings

  • Longest palindromic subsequence
  • Form a palindrome with minimum insertions
  • Min num of deletions and insertions to make string s1 equal to s2
  • Shortest common supersequence
  • Longest common substring/subarray
  • Longest palindromic substring
  • Longest repeating subsequence
  • Longest common subsequence
  • Print Longest common subsequence

DP on string

  • Distinct occurence
  • Wildcard pattern matching
  • Longest valid parentheses
  • Word break
  • Word wrap
  • Interleaved strings
  • Edit distance
  • Word break II

DP on stocks

  • Best time to buy and sell stock
  • Best time to buy and sell stock III
  • Best time to buy and sell stock IV
  • Best time to buy and sell stock with cooldown
  • Best time to buy and sell stock with transaction fee
  • Best time to buy and sell stock II

DP on partition and MCM

  • Minimum cost to cut stick
  • Burst balloons
  • Boolean Parenthesization
  • Palindrom partitioning
  • Partition array for max sum
  • Max rectangles area with all 1s
  • Count square submatrices
  • Matrix chain multiplication

Heaps - Data structure· 25

Basic patterns

  • What is heap? Understand the data structure
  • Min heap implementation
  • Max heap implementation
  • Convert min heap to max heap

Top k pattern

  • kth largest in array
  • kth smallest in array
  • Top k frequent elements
  • Top k frequent words
  • Frequency sort
  • kth largest num in streams
  • Reorganize string
  • Reorganize string k distance apart
  • kth smallest sum of matrix
  • ugly num II

Merge k sorted pattern

  • Merge k sorted array
  • k pairs with smallest sum
  • k smallest nums in M sorted list

Two heaps pattern

  • Find median from data stream
  • Sliding window median
  • Maximum capital/IPO

Minimum number pattern

  • Minimum cost to connect ropes
  • Meeting room II
  • Minimum cost to hire k workers
  • Minimum num of refueling stops
  • Minimum num of CPU

Trie - Data structure· 6

  • Implement trie
  • Search suggestions system
  • Replace words
  • Design add and search words
  • Word search II
  • Stream of characters

String· 14

  • Implement Atoi
  • Minimum bracket reversals
  • Remove all adjacent duplicates
  • Hashing in strings
  • Print all anagrams
  • Z - Function
  • Shortest palindrome
  • Circle of strings
  • Roman numerals to decimals
  • KMP algo
  • Count and say
  • Rabin karp algo
  • Boyer moor algo
  • Longest happy prefix