← All DSA Sheets

Shradha Khapra · Apna College

Shradha Didi DSA Sheet

The main Apna College practice sheet, organized by topic.

375 practice entries · Source checked

0 / 375 completed0%
About this source edition

375-row main sheet; bonus tab excluded

“Source checked” is when this edition was retrieved, not a claim that the creator updated it then.

Original sheet ↗

Arrays

0 / 26
DoneProblemLevelPracticeVideo
Maximum and Minimum Element in an Array —Open ↗—
Reverse the Array —Open ↗—
Maximum-Subarray —Open ↗—
Contains Duplicate —Open ↗—
Chocolate Distribution Problem —Open ↗—
Search in Rotated Sorted Array —Open ↗—
Next Permutation —Open ↗—
Best time to Buy and Sell Stock —Open ↗—
Repeat and Missing Number Array —Open ↗—
Kth-Largest Element in an Array —Open ↗—
Trapping Rain Water —Open ↗—
Product of Array Except Self —Open ↗—
Maximum Product Subarray —Open ↗—
Find Minimum in Rotated Sorted Array —Open ↗—
Find Pair with Sum in Sorted & Rotated Array —Open ↗—
3Sum —Open ↗—
Container With Most Water —Open ↗—
Given Sum Pair —Open ↗—
Kth - Smallest Element —Open ↗—
Merge Overlapping Intervals —Open ↗—
Find Minimum Number of Merge Operations to Make an Array Palindrome —Open ↗—
Given an Array of Numbers Arrange the Numbers to Form the Biggest Number —Open ↗—
Space Optimization Using Bit Manipulations —Open ↗—
Subarray Sum Divisible K —Open ↗—
Print all Possible Combinations of r Elements in a Given Array of Size n —Open ↗—
Mo's Algorithm —Open ↗—

Strings

0 / 22
DoneProblemLevelPracticeVideo
Valid Palindrome —Open ↗—
Valid Anagram —Open ↗—
Valid parentheses —Open ↗—
Remove Consecutive Characters —Open ↗—
Longest Common Prefix —Open ↗—
Convert a Sentence into its Equivalent Mobile Numeric Keypad Sequence —Open ↗—
Print all the Duplicates in the Input String —Open ↗—
Longest Substring without Repeating Characters —Open ↗—
Longest Repeating Character Replacement —Open ↗—
Group Anagrams —Open ↗—
Longest Palindromic Substring —Open ↗—
Palindromic Substrings —Open ↗—
Next Permutation —Open ↗—
Count Palindromic Subsequences —Open ↗—
Smallest Window in a String Containing all the Characters of Another String —Open ↗—
Wildcard String Matching —Open ↗—
Longest Prefix Suffix —Open ↗—
Rabin-Karp Algorithm for Pattern Searching —Open ↗—
Transform One String to Another using Minimum Number of Given Operation —Open ↗—
Minimum Window Substring —Open ↗—
Boyer Moore Algorithm for Pattern Searching —Open ↗—
Word Wrap —Open ↗—

2D Arrays

0 / 10
DoneProblemLevelPracticeVideo
Zigzag (or diagonal) Traversal of Matrix —Open ↗—
Set Matrix Zeroes —Open ↗—
Spiral Matrix —Open ↗—
Rotate Image —Open ↗—
Word Search —Open ↗—
Find the Number of Islands | Set 1 (Using DFS) —Open ↗—
Given a Matrix of ‘O’ and ‘X’, Replace ‘O’ with ‘X’ if Surrounded by ‘X’ —Open ↗—
Find a Common Element in all Rows of a Given Row-Wise Sorted Matrix —Open ↗—
Create a Matrix with Alternating Rectangles of O and X —Open ↗—
Maximum Size Rectangle of all 1s —Open ↗—

Searching & Sorting

0 / 23
DoneProblemLevelPracticeVideo
Permute Two Arrays such that Sum of Every Pair is Greater or Equal to K —Open ↗—
counting sort —Open ↗—
find common elements three sorted arrays —Open ↗—
Searching in an array where adjacent differ by at most k —Open ↗—
ceiling in a sorted array —Open ↗—
Piar with given difference —Open ↗—
majority element —Open ↗—
count triplets with sum smaller that a given value —Open ↗—
Maximum Sum Subsequence with no adjacent elements —Open ↗—
Merge Sorted Arrays using O(1) Space —Open ↗—
Inversion of Array —Open ↗—
Find Duplicates in O(n) Time and O(1) Extra Space —Open ↗—
Radix Sort —Open ↗—
Product of Array except itself —Open ↗—
Make all Array Elements Equal —Open ↗—
Check if Reversing a Sub Array Make the Array Sorted —Open ↗—
Find Four Elements that Sum to a Given Value —Open ↗—
Median of Two Sorted Array with Different Size —Open ↗—
Median of Stream of Integers Running Integers —Open ↗—
Print Subarrays with 0 Sum —Open ↗—
Aggressive Cows —Open ↗—
Allocate Minimum number of Pages —Open ↗—
Minimum Swaps to Sort —Open ↗—

Backtracking

0 / 21
DoneProblemLevelPracticeVideo
Backtracking Set 2 Rat in a Maze —Open ↗—
Combinational Sum —Open ↗—
Crossword-Puzzle —Open ↗—
Longest Possible Route in a Matrix with Hurdles —Open ↗—
Printing all solutions in N-Queen Problem —Open ↗—
Solve the Sudoku —Open ↗—
Partition Equal Subset Sum —Open ↗—
M Coloring Problem —Open ↗—
Knight Tour —Open ↗—
Soduko —Open ↗—
Remove Invalid Parentheses —Open ↗—
Word Break Problem using Backtracking —Open ↗—
Print all Palindromic Partitions of a String —Open ↗—
Find Shortest Safe Route in a Path with Landmines —Open ↗—
Partition of Set into K Subsets with Equal Sum —Open ↗—
Backtracking set-7 hamiltonian cycle —Open ↗—
tug-of-war —Open ↗—
Maximum Possible Number by doing at most K swaps —Open ↗—
Backtracking set-8 solving cryptarithmetic puzzles —Open ↗—
Find paths from corner cell to middle cell in maze —Open ↗—
Arithmetic Expressions —Open ↗—

Linked List

0 / 26
DoneProblemLevelPracticeVideo
Reverse Linked List —Open ↗—
Linked List Cycle —Open ↗—
Merge Two Sorted Lists —Open ↗—
Delete without Head node —Open ↗—
Remove duplicates from an unsorted linked list —Open ↗—
Sort a linked list of 0s-1s-or-2s —Open ↗—
Multiply two numbers represented linked lists —Open ↗—
Remove nth node from end of list —Open ↗—
Reorder List —Open ↗—
Detect and remove loop in a linked list —Open ↗—
Write a Function to get the Intersection Point of two Linked Lists —Open ↗—
Flatten a linked list with next and child pointers —Open ↗—
Linked list in zig-zag fashion —Open ↗—
Reverse a doubly linked list —Open ↗—
Delete nodes which have a greater value on right side —Open ↗—
Segregate even and odd Elements in a Linked List —Open ↗—
Point to next higher value node in a linked list with an Arbitrary Pointer —Open ↗—
Rearrange a given linked list in place —Open ↗—
Sort Biotonic Doubly Linked Lists —Open ↗—
Merge K Sorted Lists —Open ↗—
Merge sort for linked list —Open ↗—
Quicksort on singly-linked list —Open ↗—
Sum of two linked lists —Open ↗—
Flattening a linked list —Open ↗—
Clone a linked list with next and random Pointer —Open ↗—
Subtract two numbers represented as linked lists —Open ↗—

Stacks & Queues

0 / 27
DoneProblemLevelPracticeVideo
Implement two stacks in an Array —Open ↗—
Evaluation of Postfix Expression —Open ↗—
Implement Stack using Queues —Open ↗—
Queue Reversal —Open ↗—
Implement Stack Queue using Deque —Open ↗—
Reverse first k elements of queue —Open ↗—
Design Stack with Middle Operation —Open ↗—
Infix to Postfix —Open ↗—
Design and Implement Special stack —Open ↗—
Longest Valid String —Open ↗—
Find if an expression has duplicate parenthesis or not —Open ↗—
Stack permutations check if an array is stack permutation of other —Open ↗—
Count natural numbers whose permutation greater number —Open ↗—
Sort a stack using Recursion —Open ↗—
Queue based approach for first non repeating character in a stream —Open ↗—
The Celebrity Problem —Open ↗—
Next larger Element —Open ↗—
Distance of nearest cell —Open ↗—
Rotten-oranges —Open ↗—
Next smaller element —Open ↗—
Circular-tour —Open ↗—
Efficiently implement k-stacks single array —Open ↗—
The celebrity problem —Open ↗—
Iterative tower of hanoi —Open ↗—
Find the maximum of minimums for every window size in a given array —Open ↗—
lru cache implementation —Open ↗—
Find a tour that visits all stations —Open ↗—

Greedy

0 / 22
DoneProblemLevelPracticeVideo
Activity selection problem greedy algo —Open ↗—
Greedy algorithm to find minimum number of coins —Open ↗—
Minimum sum two numbers formed digits array-2 —Open ↗—
Minimum sum absolute difference pairs two arrays —Open ↗—
Find maximum height pyramid from the given array of objects —Open ↗—
Minimum cost for acquiring all coins with k extra coins allowed with every coin —Open ↗—
Find maximum equal sum of every three stacks —Open ↗—
Job sequencing problem —Open ↗—
Greedy algorithm egyptian fraction —Open ↗—
Fractional knapsack problem —Open ↗—
Maximum length chain of pairs —Open ↗—
Find smallest number with given number of digits and digit sum —Open ↗—
Maximize sum of consecutive differences circular-array —Open ↗—
paper-cut minimum number squares —Open ↗—
Lexicographically smallest array-k consecutive swaps —Open ↗—
Problems-CHOCOLA —Open ↗—
Find minimum time to finish all jobs with given constraints —Open ↗—
Job sequencing using disjoint set union —Open ↗—
Rearrange characters string such that no two adjacent are same —Open ↗—
Minimum edges to reverse to make path from a source to a destination —Open ↗—
Minimize Cash Flow among a given set of friends who have borrowed money from each other —Open ↗—
Minimum Cost to cut a board into squares —Open ↗—

Binary Trees

0 / 33
DoneProblemLevelPracticeVideo
Maximum Depth of Binary Tree —Open ↗—
Reverse Level Order Traversal —Open ↗—
Subtree of Another Tree —Open ↗—
Invert Binary Tree —Open ↗—
Binary Tree Level Order Traversal —Open ↗—
Left View of Binary Tree —Open ↗—
Right View of Binary Tree —Open ↗—
ZigZag Tree Traversal —Open ↗—
Create a mirror tree from the given binary tree —Open ↗—
Leaf at same level —Open ↗—
Check for Balanced Tree —Open ↗—
Transform to Sum Tree —Open ↗—
Check if Tree is Isomorphic —Open ↗—
Same Tree —Open ↗—
Construct Binary Tree from Preorder and Inorder Traversal —Open ↗—
Height of Binary Tree —Open ↗—
Diameter of a Binary Tree —Open ↗—
Top View of Binary Tree —Open ↗—
Bottom View of Binary Tree —Open ↗—
Diagonal Traversal of Binary Tree —Open ↗—
Boundary Traversal of binary tree —Open ↗—
Construct Binary Tree from String with Brackets —Open ↗—
Minimum swap required to convert binary tree to binary search tree —Open ↗—
Duplicate subtree in Binary Tree —Open ↗—
Check if a given graph is tree or not —Open ↗—
Lowest Common Ancestor in a Binary Tree —Open ↗—
Min distance between two given nodes of a Binary Tree —Open ↗—
Duplicate Subtrees —Open ↗—
Kth ancestor of a node in binary tree —Open ↗—
Binary Tree Maximum Path Sum —Open ↗—
Serialize and Deserialize Binary Tree —Open ↗—
Binary Tree to DLL —Open ↗—
Print all k-sum paths in a binary tree —Open ↗—

Binary Search Trees

0 / 21
DoneProblemLevelPracticeVideo
Lowest Common Ancestor of a Binary Search Tree —Open ↗—
Binary Search Tree | Set 1 (Search and Insertion) —Open ↗—
Minimum element in BST —Open ↗—
Predecessor and Successor —Open ↗—
Check whether BST contains Dead End —Open ↗—
Binary Tree to BST —Open ↗—
Kth largest element in BST —Open ↗—
Validate Binary Search Tree —Open ↗—
Kth Smallest Element in a BST —Open ↗—
Delete Node in a BST —Open ↗—
Flatten BST to sorted list —Open ↗—
Preorder to Postorder —Open ↗—
Count BST nodes that lie in a given range —Open ↗—
Populate Inorder Successor for all Nodes —Open ↗—
Convert Normal BST to Balanced BST —Open ↗—
Merge two BSTs —Open ↗—
Given n appointments, find all conflicting appointments —Open ↗—
Replace every element —Open ↗—
Construct BST from given preorder traversal —Open ↗—
Find median of BST in O(n) time and O(1) space —Open ↗—
Largest BST in a Binary Tree —Open ↗—

Heaps & Hashing

0 / 28
DoneProblemLevelPracticeVideo
Choose k array elements such that difference of maximum and minimum is minimized —Open ↗—
Heap Sort —Open ↗—
Top K Frequent Elements —Open ↗—
k largest elements in an array —Open ↗—
Next Greater Element —Open ↗—
K’th Smallest/Largest Element in Unsorted Array —Open ↗—
Find the maximum repeating number in O(n) time and O(1) extra space —Open ↗—
K-th smallest element after removing some integers from natural numbers —Open ↗—
Find k closest elements to a given value —Open ↗—
K’th largest element in a stream —Open ↗—
Connect Ropes —Open ↗—
Cuckoo Hashing —Open ↗—
Itinerary from a List of Tickets —Open ↗—
Largest Subarray with 0 Sum —Open ↗—
Count distinct elements in every window of size k —Open ↗—
Group Shifted Strings —Open ↗—
Merge K Sorted lists —Open ↗—
Find Median from Data Stream —Open ↗—
Sliding Window Maximum —Open ↗—
Find the smallest positive number —Open ↗—
Find Surpasser Count of each element in array —Open ↗—
Tournament Tree and Binary Heap —Open ↗—
Check for palindrome —Open ↗—
Length of the largest subarray with contiguous elements —Open ↗—
Palindrome Substring Queries —Open ↗—
Subarray distinct elements —Open ↗—
Find the recurring function —Open ↗—
K maximum sum combinations from two arrays —Open ↗—

Graphs

0 / 40
DoneProblemLevelPracticeVideo
BFS —Open ↗—
DFS —Open ↗—
Flood Fill Algorithm —Open ↗—
Number of Triangles —Open ↗—
Detect cycle in a graph —Open ↗—
Detect cycle in an undirected graph —Open ↗—
Rat in a Maze Problem —Open ↗—
Steps by Knight —Open ↗—
Clone graph —Open ↗—
Number of Operations to Make Network Connected —Open ↗—
Dijkstra’s shortest path algorithm —Open ↗—
Topological Sort —Open ↗—
Oliver and the Game —Open ↗—
Minimum time taken by each job to be completed given by a Directed Acyclic Graph —Open ↗—
Find whether it is possible to finish all tasks or not from given dependencies —Open ↗—
Find the number of islands —Open ↗—
Prim's Algo —Open ↗—
Negative Weighted Cycle —Open ↗—
Floyd Warshall —Open ↗—
Graph Coloring —Open ↗—
Snakes and Ladders —Open ↗—
Kosaraju's Theorem —Open ↗—
Journey to moon —Open ↗—
Vertex Cover —Open ↗—
M Coloring Problem —Open ↗—
Cheapest Flights Within K Stops —Open ↗—
Find if there is a path of more than k length from a source —Open ↗—
Bellman Ford —Open ↗—
Bipartitie Graph —Open ↗—
Word-Ladder —Open ↗—
Allen Dictionary —Open ↗—
Kruskals MST —Open ↗—
Total number spanning trees graph —Open ↗—
Travelling Salesman —Open ↗—
Find longest path directed acyclic graph —Open ↗—
Two Clique Problem —Open ↗—
Minimise the cash flow —Open ↗—
Chinese postman —Open ↗—
Water Jug —Open ↗—
Water Jug 2 —Open ↗—

Tries

0 / 6
DoneProblemLevelPracticeVideo
Construct a trie from scratch —Open ↗—
Print unique rows in a given boolean matrix —Open ↗—
Word Break Problem | (Trie solution) —Open ↗—
Given a sequence of words, print all anagrams together —Open ↗—
Find shortest unique prefix for every word in a given list —Open ↗—
Implement a Phone Directory —Open ↗—

DP

0 / 54
DoneProblemLevelPracticeVideo
Knapsack with Duplicate Items —Open ↗—
BBT counter —Open ↗—
Reach a given score —Open ↗—
Maximum difference of zeros and ones in binary string —Open ↗—
Climbing Stairs —Open ↗—
Permutation Coefficient —Open ↗—
Longest Repeating Subsequence —Open ↗—
Pairs with specific difference —Open ↗—
Longest subsequence-1 —Open ↗—
Coin Change —Open ↗—
LIS —Open ↗—
Longest Common Subsequence —Open ↗—
Word Break —Open ↗—
Combination Sum IV —Open ↗—
House Robber —Open ↗—
Houe Robber 2 —Open ↗—
Decode Ways —Open ↗—
Unique Paths —Open ↗—
Jumps Game —Open ↗—
Knapsack Problem —Open ↗—
nCr —Open ↗—
Catalan Number —Open ↗—
Edit Distance —Open ↗—
Subset Sum —Open ↗—
Gold mine —Open ↗—
Assembly Line Scheduling —Open ↗—
Maximize The Cut Segments —Open ↗—
Maximum sum increasing subsequence —Open ↗—
Count all subsequences having product less than K —Open ↗—
Maximum sum increasing subsequence —Open ↗—
Egg dropping puzzle —Open ↗—
Max length chain —Open ↗—
Largest Square in Matrix —Open ↗—
Maximum Path Sum —Open ↗—
Minimum Number of Jumps —Open ↗—
Minimum removals from array to make max – min <= K —Open ↗—
Longest Common Substring —Open ↗—
Partition Equal Subset Sum —Open ↗—
Longest Palindromic Subsequnce —Open ↗—
Count Palindromic Subsequences —Open ↗—
Longest Palindromic Substring —Open ↗—
Longest Alternating Sequence —Open ↗—
Weighted Job Scheduling —Open ↗—
Coin Game —Open ↗—
Coin Game Winner —Open ↗—
Optimal Strategy for a game —Open ↗—
Word Wrap —Open ↗—
Mobile numeric keypad —Open ↗—
Maximum Length of Pair Chain —Open ↗—
Matrix Chain Multiplication —Open ↗—
Maximum profit by buying and selling a share at most twice —Open ↗—
Optimal BST —Open ↗—
Largest Submatrix with sum 0 —Open ↗—
Largest area rectangular sub-matrix with equal number of 1’s and 0’s —Open ↗—

Bit Manipulation

0 / 10
DoneProblemLevelPracticeVideo
Count set bits in an integer —Open ↗—
Find the two non-repeating elements in an array of repeating elements —Open ↗—
Program to find whether a no is power of two —Open ↗—
Find position of the only set bit —Open ↗—
Count number of bits to be flipped to convert A to B —Open ↗—
Count total set bits in all numbers from 1 to n —Open ↗—
Copy set bits in a range —Open ↗—
Calculate square of a number without using *, / and pow() —Open ↗—
Divide two integers without using multiplication, division and mod operator —Open ↗—
Power Set —Open ↗—

Segment Trees

0 / 6
DoneProblemLevelPracticeVideo
Range Sum Query - Immutable —Open ↗—
Range Minimum Query —Open ↗—
Range Sum Query - Mutable —Open ↗—
Create Sorted Array through Instructions —Open ↗—
Count of Range Sum —Open ↗—
Count of Smaller Numbers After Self —Open ↗—