Interview preparation
DSA interview questions for Data Engineers
Every question starts with a direct answer you could say out loud, then explains why, when and what goes wrong. Tick questions off as you practise.
DSA problems by topic and pattern
Topics run from basic to advanced, and each topic is split into the patterns interviewers test. Every problem has a full DataDank solution and a link to try it on LeetCode or another free judge.
248 problems in 17 topics, from basic to advanced. 0 of 248 done.
Arrays0/20
Pattern lesson: Arrays and Hashing: Sets, Hash Maps, Prefix Sums and Intervals
Array Basics1
Prefix Sum6
- Find Pivot IndexEasyLeetCode (opens in a new tab)
- Product of Array Except SelfMediumLeetCode (opens in a new tab)
- Subarray Sum Equals KMediumLeetCode (opens in a new tab)
- Subarray Sums Divisible by KMediumLeetCode (opens in a new tab)
- Contiguous ArrayMediumLeetCode (opens in a new tab)
- Shortest Subarray with Sum at Least KHardLeetCode (opens in a new tab)
Kadane's Algorithm5
- Maximum SubarrayMediumLeetCode (opens in a new tab)
- Maximum Product SubarrayMediumLeetCode (opens in a new tab)
- Maximum Subarray Sum with One DeletionMediumLeetCode (opens in a new tab)
- Maximum Absolute Sum of Any SubarrayMediumLeetCode (opens in a new tab)
- Maximum Sum Circular SubarrayMediumLeetCode (opens in a new tab)
Matrix3
Cyclic Sort5
Hashing0/9
Pattern lesson: Arrays and Hashing: Sets, Hash Maps, Prefix Sums and Intervals
- Contains DuplicateEasyLeetCode (opens in a new tab)
- Valid AnagramEasyLeetCode (opens in a new tab)
- Two SumEasyLeetCode (opens in a new tab)
- First Unique Character in a StringEasyLeetCode (opens in a new tab)
- Longest PalindromeEasyLeetCode (opens in a new tab)
- Ransom NoteEasyLeetCode (opens in a new tab)
- Valid SudokuMediumLeetCode (opens in a new tab)
- Group AnagramsMediumLeetCode (opens in a new tab)
- Longest Consecutive SequenceMediumLeetCode (opens in a new tab)
Bit Manipulation0/7
Pattern lesson: Arrays and Hashing: Sets, Hash Maps, Prefix Sums and Intervals
- Number of 1 BitsEasyLeetCode (opens in a new tab)
- Reverse BitsEasyLeetCode (opens in a new tab)
- Single NumberEasyLeetCode (opens in a new tab)
- Counting BitsEasyLeetCode (opens in a new tab)
- Complement of Base 10 IntegerEasyLeetCode (opens in a new tab)
- Sum of Two IntegersMediumLeetCode (opens in a new tab)
- Single Number IIIMediumLeetCode (opens in a new tab)
Two Pointers0/17
Pattern lesson: Two Pointers: Converging, Read-Write and Partitioning Templates
- Valid Palindrome IIEasyLeetCode (opens in a new tab)
- Valid PalindromeEasyLeetCode (opens in a new tab)
- Move ZeroesEasyLeetCode (opens in a new tab)
- Remove Duplicates from Sorted ArrayEasyLeetCode (opens in a new tab)
- Squares of a Sorted ArrayEasyLeetCode (opens in a new tab)
- Segregate 0s and 1sEasyGeeksforGeeks (opens in a new tab)
- Backspace String CompareEasyLeetCode (opens in a new tab)
- Two Sum IIMediumLeetCode (opens in a new tab)
- 3SumMediumLeetCode (opens in a new tab)
- Container With Most WaterMediumLeetCode (opens in a new tab)
- Sort ColorsMediumLeetCode (opens in a new tab)
- 3Sum ClosestMediumLeetCode (opens in a new tab)
- Triplets with Smaller SumMediumGeeksforGeeks (opens in a new tab)
- Subarray Product Less Than KMediumLeetCode (opens in a new tab)
- 4SumMediumLeetCode (opens in a new tab)
- Shortest Unsorted Continuous SubarrayMediumLeetCode (opens in a new tab)
- Trapping Rain WaterHardLeetCode (opens in a new tab)
Sliding Window0/13
Pattern lesson: Sliding Window: Fixed, Variable and Monotonic-Deque Templates
- Best Time to Buy and Sell StockEasyLeetCode (opens in a new tab)
- Max Sum Subarray of Size KEasyGeeksforGeeks (opens in a new tab)
- Longest Substring Without Repeating CharactersMediumLeetCode (opens in a new tab)
- Longest Repeating Character ReplacementMediumLeetCode (opens in a new tab)
- Permutation in StringMediumLeetCode (opens in a new tab)
- Minimum Size Subarray SumMediumLeetCode (opens in a new tab)
- Longest K Unique Characters SubstringMediumGeeksforGeeks (opens in a new tab)
- Fruit Into BasketsMediumLeetCode (opens in a new tab)
- Max Consecutive Ones IIIMediumLeetCode (opens in a new tab)
- Find All Anagrams in a StringMediumLeetCode (opens in a new tab)
- Minimum Window SubstringHardLeetCode (opens in a new tab)
- Sliding Window MaximumHardLeetCode (opens in a new tab)
- Substring with Concatenation of All WordsHardLeetCode (opens in a new tab)
Stack0/14
Pattern lesson: Stacks: Matching, Evaluation and Monotonic Stack Templates
Stack Basics6
- Valid ParenthesesEasyLeetCode (opens in a new tab)
- Remove All Adjacent Duplicates In StringEasyLeetCode (opens in a new tab)
- Min StackMediumLeetCode (opens in a new tab)
- Evaluate Reverse Polish NotationMediumLeetCode (opens in a new tab)
- Remove All Adjacent Duplicates in String IIMediumLeetCode (opens in a new tab)
- Simplify PathMediumLeetCode (opens in a new tab)
Monotonic Stack8
- Next Greater Element IEasyLeetCode (opens in a new tab)
- Daily TemperaturesMediumLeetCode (opens in a new tab)
- Car FleetMediumLeetCode (opens in a new tab)
- Next Greater Element IIMediumLeetCode (opens in a new tab)
- Remove Nodes From Linked ListMediumLeetCode (opens in a new tab)
- Remove K DigitsMediumLeetCode (opens in a new tab)
- 132 PatternMediumLeetCode (opens in a new tab)
- Largest Rectangle in HistogramHardLeetCode (opens in a new tab)
Binary Search0/20
Pattern lesson: Binary Search: Exact Match, Boundaries and Searching the Answer
Classic Binary Search6
- Binary SearchEasyLeetCode (opens in a new tab)
- Ceil in Sorted ArrayEasyGeeksforGeeks (opens in a new tab)
- Time Based Key-Value StoreMediumLeetCode (opens in a new tab)
- Find First and Last Position of a ValueMediumLeetCode (opens in a new tab)
- Number of OccurrenceEasyGeeksforGeeks (opens in a new tab)
- Median of Two Sorted ArraysHardLeetCode (opens in a new tab)
Rotated Arrays and Peaks5
- Find Rotation CountEasyGeeksforGeeks (opens in a new tab)
- Find Minimum in Rotated Sorted ArrayMediumLeetCode (opens in a new tab)
- Search in Rotated Sorted ArrayMediumLeetCode (opens in a new tab)
- Peak Index in a Mountain ArrayMediumLeetCode (opens in a new tab)
- Find Peak ElementMediumLeetCode (opens in a new tab)
Binary Search on the Answer6
- Koko Eating BananasMediumLeetCode (opens in a new tab)
- Minimum Number of Days to Make m BouquetsMediumLeetCode (opens in a new tab)
- Aggressive CowsMediumGeeksforGeeks (opens in a new tab)
- Maximum Candies Allocated to K ChildrenMediumLeetCode (opens in a new tab)
- Capacity To Ship Packages Within D DaysMediumLeetCode (opens in a new tab)
- Split Array Largest SumHardLeetCode (opens in a new tab)
Matrix Search3
Linked List0/18
Pattern lesson: Linked Lists: Pointer Rewiring, Fast and Slow Pointers, LRU Cache
Linked List Basics5
Fast and Slow Pointers8
- Linked List CycleEasyLeetCode (opens in a new tab)
- Happy NumberEasyLeetCode (opens in a new tab)
- Middle of the Linked ListEasyLeetCode (opens in a new tab)
- Palindrome Linked ListEasyLeetCode (opens in a new tab)
- Reorder ListMediumLeetCode (opens in a new tab)
- Find the Duplicate NumberMediumLeetCode (opens in a new tab)
- Linked List Cycle IIMediumLeetCode (opens in a new tab)
- Circular Array LoopMediumLeetCode (opens in a new tab)
In-place Reversal5
Trees0/18
Pattern lesson: Binary Trees and Tries: DFS, BFS and Prefix Search Templates
Tree DFS11
- Invert Binary TreeEasyLeetCode (opens in a new tab)
- Maximum Depth of Binary TreeEasyLeetCode (opens in a new tab)
- Diameter of Binary TreeEasyLeetCode (opens in a new tab)
- Balanced Binary TreeEasyLeetCode (opens in a new tab)
- Same TreeEasyLeetCode (opens in a new tab)
- Subtree of Another TreeEasyLeetCode (opens in a new tab)
- Count Good Nodes in Binary TreeMediumLeetCode (opens in a new tab)
- Construct Binary Tree from Preorder and Inorder TraversalMediumLeetCode (opens in a new tab)
- Lowest Common Ancestor of a Binary TreeMediumLeetCode (opens in a new tab)
- Binary Tree Maximum Path SumHardLeetCode (opens in a new tab)
- Serialize and Deserialize Binary TreeHardLeetCode (opens in a new tab)
Tree BFS2
Trie5
BST0/6
Pattern lesson: Binary Search Trees: Ordering, Validation, Insert and Delete
- Convert Sorted Array to BSTEasyLeetCode (opens in a new tab)
- Validate Binary Search TreeMediumLeetCode (opens in a new tab)
- Kth Smallest Element in a BSTMediumLeetCode (opens in a new tab)
- Lowest Common Ancestor of a BSTMediumLeetCode (opens in a new tab)
- Insert into a BSTMediumLeetCode (opens in a new tab)
- Delete Node in a BSTMediumLeetCode (opens in a new tab)
Heap0/18
Pattern lesson: Heaps and Priority Queues: Top-K, Scheduling and Running Medians
Top K Elements11
- Kth Largest Element in a StreamEasyLeetCode (opens in a new tab)
- Last Stone WeightEasyLeetCode (opens in a new tab)
- Top K Frequent ElementsMediumLeetCode (opens in a new tab)
- K Closest Points to OriginMediumLeetCode (opens in a new tab)
- Kth Largest Element in an ArrayMediumLeetCode (opens in a new tab)
- Task SchedulerMediumLeetCode (opens in a new tab)
- Min Cost to Connect RopesMediumGeeksforGeeks (opens in a new tab)
- Sort Characters By FrequencyMediumLeetCode (opens in a new tab)
- Find K Closest ElementsMediumLeetCode (opens in a new tab)
- Reorganize StringMediumLeetCode (opens in a new tab)
- Maximum Frequency StackHardLeetCode (opens in a new tab)
Two Heaps4
K-way Merge3
Greedy0/17
Pattern lesson: Greedy Algorithms and Intervals: Safe Local Choices and Sweeps
Greedy Choices10
- Jump GameMediumLeetCode (opens in a new tab)
- Jump Game IIMediumLeetCode (opens in a new tab)
- Gas StationMediumLeetCode (opens in a new tab)
- Hand of StraightsMediumLeetCode (opens in a new tab)
- Merge Triplets to Form TargetMediumLeetCode (opens in a new tab)
- Partition LabelsMediumLeetCode (opens in a new tab)
- Valid Parenthesis StringMediumLeetCode (opens in a new tab)
- Maximum Length of Pair ChainMediumLeetCode (opens in a new tab)
- Minimum Add to Make Parentheses ValidMediumLeetCode (opens in a new tab)
- Remove Duplicate LettersMediumLeetCode (opens in a new tab)
Intervals7
- Meeting RoomsEasyGeeksforGeeks (opens in a new tab)
- Merge IntervalsMediumLeetCode (opens in a new tab)
- Insert IntervalMediumLeetCode (opens in a new tab)
- Non-overlapping IntervalsMediumLeetCode (opens in a new tab)
- Interval List IntersectionsMediumLeetCode (opens in a new tab)
- Meeting Rooms IIMediumGeeksforGeeks (opens in a new tab)
- My Calendar IMediumLeetCode (opens in a new tab)
Backtracking0/12
Pattern lesson: Backtracking: Subsets, Combinations, Permutations and Grid Search
Subsets and Permutations6
- Generate ParenthesesMediumLeetCode (opens in a new tab)
- SubsetsMediumLeetCode (opens in a new tab)
- PermutationsMediumLeetCode (opens in a new tab)
- Subsets IIMediumLeetCode (opens in a new tab)
- Letter Combinations of a Phone NumberMediumLeetCode (opens in a new tab)
- Letter Case PermutationMediumLeetCode (opens in a new tab)
Combinations and Search6
Graph0/27
Pattern lesson: Graphs: BFS, DFS, Topological Sort, Union-Find and Shortest Paths
Graph Traversal5
Islands (Matrix Traversal)8
- Flood FillEasyLeetCode (opens in a new tab)
- Island PerimeterEasyLeetCode (opens in a new tab)
- Number of IslandsMediumLeetCode (opens in a new tab)
- Max Area of IslandMediumLeetCode (opens in a new tab)
- Pacific Atlantic Water FlowMediumLeetCode (opens in a new tab)
- Surrounded RegionsMediumLeetCode (opens in a new tab)
- Rotting OrangesMediumLeetCode (opens in a new tab)
- Number of Closed IslandsMediumLeetCode (opens in a new tab)
Topological Sort5
Union Find5
- Graph Valid TreeMediumGeeksforGeeks (opens in a new tab)
- Number of Connected Components in an Undirected Graph with Union-FindMediumGeeksforGeeks (opens in a new tab)
- Redundant ConnectionMediumLeetCode (opens in a new tab)
- Is Graph Bipartite?MediumLeetCode (opens in a new tab)
- Path With Minimum EffortMediumLeetCode (opens in a new tab)
Shortest Paths and MST4
Dynamic Programming0/24
Pattern lesson: Dynamic Programming: States, Transitions and the Classic DP Families
1D DP9
- Climbing StairsEasyLeetCode (opens in a new tab)
- Min Cost Climbing StairsEasyLeetCode (opens in a new tab)
- House RobberMediumLeetCode (opens in a new tab)
- House Robber IIMediumLeetCode (opens in a new tab)
- Decode WaysMediumLeetCode (opens in a new tab)
- Coin ChangeMediumLeetCode (opens in a new tab)
- Word BreakMediumLeetCode (opens in a new tab)
- Longest Increasing SubsequenceMediumLeetCode (opens in a new tab)
- Best Time to Buy and Sell Stock with CooldownMediumLeetCode (opens in a new tab)
Knapsack7
- Partition Equal Subset SumMediumLeetCode (opens in a new tab)
- Coin Change IIMediumLeetCode (opens in a new tab)
- Target SumMediumLeetCode (opens in a new tab)
- 0 - 1 Knapsack ProblemMediumGeeksforGeeks (opens in a new tab)
- Subset Sum ProblemMediumGeeksforGeeks (opens in a new tab)
- Count Subsets with SumMediumGeeksforGeeks (opens in a new tab)
- Partition Into 2 Subsets with Min Sum DiffHardGeeksforGeeks (opens in a new tab)
2D DP: Strings and Grids8
- Longest Palindromic SubstringMediumLeetCode (opens in a new tab)
- Palindromic SubstringsMediumLeetCode (opens in a new tab)
- Unique PathsMediumLeetCode (opens in a new tab)
- Longest Common SubsequenceMediumLeetCode (opens in a new tab)
- Interleaving StringMediumLeetCode (opens in a new tab)
- Edit DistanceMediumLeetCode (opens in a new tab)
- Burst BalloonsHardLeetCode (opens in a new tab)
- Regular Expression MatchingHardLeetCode (opens in a new tab)
Ticks are saved in this browser only and match the ticks on the interview pages.
How to use this page
This page collects 248 DSA interview questions answered in depth (58 easy, 162 medium and 28 hard), ordered from the basics to the harder design and troubleshooting questions. They include “Majority Element: Find the Value That Fills More Than Half the Array”, “Find Pivot Index: Balance Left and Right Prefix Sums”, “Product of Array Except Self: Prefix and Suffix Products Without Division” and “Subarray Sum Equals K: Count Contiguous Slices With a Given Sum”.
Each answer opens with a short version you could say out loud in an interview, then explains why it works, shows a worked example, and lists the mistakes and follow-up questions interviewers use. If a topic is new to you, learn it in the DSA course first. Tick each question off as you practise; your progress is saved in this browser.
Concept review
- LessonBeginnerArrays and Hashing: Sets, Hash Maps, Prefix Sums and Intervals
- LessonAdvancedBacktracking: Subsets, Combinations, Permutations and Grid Search
- LessonIntermediateBinary Search: Exact Match, Boundaries and Searching the Answer
- LessonIntermediateBinary Search Trees: Ordering, Validation, Insert and Delete
- LessonIntermediateBinary Trees and Tries: DFS, BFS and Prefix Search Templates
- LessonBeginnerBit Manipulation: XOR Tricks, Masks and Fixed-Width Integers
- LessonBeginnerData Structures and Algorithms for Data Engineers: How to Prepare
- LessonAdvancedDynamic Programming: States, Transitions and the Classic DP Families
- LessonAdvancedGraphs: BFS, DFS, Topological Sort, Union-Find and Shortest Paths
- LessonIntermediateGreedy Algorithms and Intervals: Safe Local Choices and Sweeps
- LessonIntermediateHeaps and Priority Queues: Top-K, Scheduling and Running Medians
- LessonIntermediateLinked Lists: Pointer Rewiring, Fast and Slow Pointers, LRU Cache
- LessonBeginnerQueues: FIFO Buffers, Ring Buffers and Queue Design Problems
- LessonIntermediateSliding Window: Fixed, Variable and Monotonic-Deque Templates
- LessonIntermediateStacks: Matching, Evaluation and Monotonic Stack Templates
- LessonBeginnerStrings for Coding Interviews: Immutability, Scanning and Parsing
- LessonBeginnerTwo Pointers: Converging, Read-Write and Partitioning Templates

