Menu

All DSA questions

DSA interview questions
#QuestionDifficultyTypeDone
1Binary Search: Find a Target in a Sorted Array in O(log n)Easycoding
2Contains Duplicate: Detect Whether Any Value Appears TwiceEasycoding
3Invert Binary Tree: Recursive and Iterative Mirror SolutionsEasycoding
4Linked List Cycle: Floyd's Fast and Slow PointersEasycoding
5Majority Element: Find the Value That Fills More Than Half the ArrayEasycoding
6Maximum Depth of Binary Tree: Recursive DFS, Iterative DFS and BFSEasycoding
7Merge Two Sorted Lists: Dummy Head Iteration and RecursionEasycoding
8Move Zeroes: Shift Zeros to the End While Keeping OrderEasycoding
9Reverse Linked List: Iterative and Recursive SolutionsEasycoding
10Two Sum: Find Two Indices That Add Up to a TargetEasycoding
11Valid Anagram: Check Whether Two Strings Use the Same LettersEasycoding
12Valid Palindrome: Check a Phrase While Ignoring Case and PunctuationEasycoding
133Sum: Find All Unique Triplets That Sum to ZeroMediumcoding
14Add Two Numbers: Digit-by-Digit Addition on Linked ListsMediumcoding
15Clone Graph: Deep-Copy a Connected Graph with a Hash Map and BFS or DFSMediumcoding
16Combination Sum II: Use Each Value Once and Avoid Duplicate AnswersMediumcoding
17Combination Sum: Reach a Target with Reusable Values via BacktrackingMediumcoding
18Container With Most Water: Maximise Area Between Two LinesMediumcoding
19Copy List with Random Pointer: Hash Map and Interleaving SolutionsMediumcoding
20Course Schedule II: Return a Valid Course Order with Topological SortMediumcoding
21Course Schedule: Detect a Cycle in a Prerequisite Graph with Kahn's AlgorithmMediumcoding
22Encode and Decode Strings: Serialise a List of Strings SafelyMediumcoding
23Find First and Last Position of a Value: Lower and Upper Bound Binary SearchMediumcoding
24Find Minimum in Rotated Sorted Array: Binary Search Against the Right EndMediumcoding
25Find the Duplicate Number: Cycle Detection on an ArrayMediumcoding
26Graph Valid Tree: Check Edge Count, Connectivity and Cycles with Union-FindMediumcoding
27Group Anagrams: Bucket Words That Share the Same LettersMediumcoding
28Insert Interval: Add a Range to a Sorted List and Merge OverlapsMediumcoding
29Koko Eating Bananas: Binary Search on the AnswerMediumcoding
30Letter Combinations of a Phone Number: Cartesian Product by BacktrackingMediumcoding
31Longest Consecutive Sequence: Longest Run of Consecutive Integers in O(n)Mediumcoding
32LRU Cache: Hash Map Plus Doubly Linked List for O(1) OperationsMediumcoding, architecture
33Max Area of Island: Largest Connected Land Region with Flood FillMediumcoding
34Maximum Subarray: Largest Sum of a Contiguous Slice with Kadane's AlgorithmMediumcoding
35Merge Intervals: Combine Every Overlapping RangeMediumcoding
36Non-overlapping Intervals: Fewest Removals to Eliminate OverlapsMediumcoding
37Number of Connected Components in an Undirected Graph with Union-FindMediumcoding
38Number of Islands: Count Connected Land Cells with BFS, DFS or Union-FindMediumcoding
39Pacific Atlantic Water Flow: Reverse Multi-Source BFS from Both OceansMediumcoding
40Palindrome Partitioning: Split a String into Palindromes by BacktrackingMediumcoding
41Permutations: Every Ordering of Distinct Values with BacktrackingMediumcoding
42Product of Array Except Self: Prefix and Suffix Products Without DivisionMediumcoding
43Redundant Connection: Find the Edge That Closes a Cycle with Union-FindMediumcoding
44Remove Nth Node From End of List: One Pass with a Gap of nMediumcoding
45Reorder List: Find the Middle, Reverse, Then InterleaveMediumcoding
46Rotate Image: Turn a Square Matrix 90 Degrees Clockwise in PlaceMediumcoding
47Rotting Oranges: Minutes to Spread via Level-by-Level Multi-Source BFSMediumcoding
48Search a 2D Matrix: Binary Search over a Flattened Sorted GridMediumcoding
49Search in Rotated Sorted Array: One-Pass Binary SearchMediumcoding
50Set Matrix Zeroes: Zero Out Rows and Columns in PlaceMediumcoding
51Sort Colors: One-Pass Three-Way Partition of 0s, 1s and 2sMediumcoding
52Spiral Matrix: Read a Grid in Clockwise Spiral OrderMediumcoding
53Subarray Sum Equals K: Count Contiguous Slices With a Given SumMediumcoding
54Subsets II: Power Set Without Duplicates When Values RepeatMediumcoding
55Subsets: Generate the Power Set with Include/Exclude BacktrackingMediumcoding
56Surrounded Regions: Capture Enclosed Cells by Flood-Filling from the BorderMediumcoding
57Time Based Key-Value Store: Versioned Lookups with Binary SearchMediumcoding, architecture
58Top K Frequent Elements: Return the k Most Common ValuesMediumcoding
59Two Sum II: Find a Pair With a Target Sum in a Sorted ArrayMediumcoding
60Valid Sudoku: Check Rows, Columns and Boxes for Repeated DigitsMediumcoding
61Word Search: Trace a Word Through a Letter Grid with DFS BacktrackingMediumcoding
62Median of Two Sorted Arrays: Partition Binary Search in O(log min(m, n))Hardcoding
63Merge k Sorted Lists: Min-Heap and Divide-and-Conquer SolutionsHardcoding
64N-Queens: Place Non-Attacking Queens Row by Row with BacktrackingHardcoding
65Reverse Nodes in k-Group: In-Place Group Reversal on a Linked ListHardcoding
66Trapping Rain Water: Total Water Held Between Elevation BarsHardcoding
67Word Search II: Find Many Words in a Grid with a Trie and BacktrackingHardcoding

Ticks are saved in this browser only. No account needed.

Concept review

Continue preparing

Search
Filter by type