Lecture-Questions
Lecture-Questions
Lecture-2 ✔️
Sieve Method
Euclidean Division
Segmented Sieve
Lecture-3 ✔️
Modular Exponentiation
Lecture-Questions 1
All unique pairs in an array whose sum is k
Lecture-4 ✔️
Maximum sum of subarray of size k (Sliding window)
Lecture-5
SumPower Problem ✔️
Prefix Sum Problem- Consider a problem where you are given an array of size
n and for each query you need to compute the sum of elements in a subarray b/w
indices l and r. You also need to find sum of odd numbers b/w l and r. For each
query you’re asked to find max freq of any number in sub-array. (Keep 2d array
for frequency, 1d for prefix sums)
✔️
Lecture-Questions 2
Lecture-6 ✔️
Find next (right) greatest element
StockSpan
Lecture-7
Celebrity Problem ✔️
Trapping Rainwater Problem ✔️
atleast two different alternates ✔️
Kth smallest element of an array without sorting. Implement
Lecture-8
STL
Lecture-9 ✔️
✔️
Find single element in sorted array where all except one element
exist twice. O(logn)
Find a key
Lecture - 10 ✔️
Kth missing positive integer in sorted array ☑️
Aggressive Cows ✔️
Allocate Minimum Pages(Book Allocation Problem) ✅
Given an array arr[] and an integer k, where arr[i] denotes the number of pages of
a book and k denotes total number of students. All the books need to be allocated
to k students in contiguous manner, with each student getting at least one book.
Painter Partition ✅
Least Capacity to ship packages within d days ✔️
Median of 2 sorted arrays of different sizes ✅
Search in 2D array (matrix -rows and columns are sorted) ✔️
LECTURE - 11 ✅
MaxVote
a+b stack
Lecture-Questions 4
LECTURE - 12 ✅
Find max element using min Priority queue O(nlogn)
Lecture - 13
✔️
Find the kth smallest element in an unsorted array using median
of medians algorithm
Tournament Sorting ✔️
✔️
Lab- kth smallest element in rows, column sorted
matrix
Lecture - 14
Separate indices of linked list (odd,even) ✅
Separate data values of linked list (odd, even) ✅
Middle of linked list ✅
Lecture-Questions 5
Detect cycle, 1st node of cycle and remove cycle ✔️
Remove nth node from the end ✔️
Remove every kth node ✅
Right rotation by k places ✔️
Palindrome ✔️
Lecture 15
Flatten a doubly linked list- using down pointers ✔️
Clone a linked list with random pointers ✔️
Lecture 16- Recursions
✅
Find the super digit for a given array
✅
Rat in a maze It can only move up or down, left or right, Return all
possible paths
Lecture- 17 Backtracking ✔️
Palindrome Partition- Return all possibilities ✔️
Two button Problem- Hint: try reversing the problem ☑️
Fair distribution of cookies, k is no of students Calculate the min
☑️
unfairness (Unfairness- Max total cookies obtained by single
children in distribution
N-Queen Problem ☑️
Sum of subsets ✔️
Graph Coloring ☑️
Hamiltonion graphs ✔️
Lecture 18
min n- digit no with digits in increasing order ✔️
(4,6,7,7): 46,47,67,77,467,477,677,4677
Word search ✔️
Lecture-Questions 7
Matchstick to square (1,1,2,2,2), (3,3,3,3,4)
Lecture 19
logical shift
arithmetic shift
set ✔️
toggle✔️
clear✔️
modify
Lecture 20 ✔️
all numbers are repeated except 2(x,y). Find x, y ☑️
Lecture-Questions 8
✅
An array has n+2 elements in the range 1 to n and exactly two
numbers x and y are repeated. find x and y
✔️
one, find the length of longest sequence of 1s, you can create in
its binary representation
✔️
Given a positive n number, print next smallest no than n having
same no of 1s
LECTURE 21 Greedy
Dijsktra✔️
Prims ✔️
Kruskal ✔️
Lecture 22
Disjoint sets: Find set, union
linked list (union by size) ✔️
tree
Path compression ✔️
Union by rank and size ✔️
Strongly connected components ✔️
dfs ✔️
bfs - confirm if method correct ✔️
Q1: Detect cycle in undirected graph ✔️
Q2: City and Flood ✔️
Kahns for cycle detection ✔️
Kosaraju ✔️
Tarjan Algorithm for BRIDGE ✔️
Tarjan for articulation point
Tarjan for scc
Lecture 23
Lecture-Questions 10
Road Decoration ✔️
Lecture 24
m-ary tree ☑️
convert a tree to a left child right sibling binary tree, first child of a node is stored
in left pointer, all other siblings become right children of their intermediate siblings
✔️
Diameter of a tree- longest path between two nodes
Lecture-Questions 11