PrepPilotPractise free

Data Structures & Algorithms interview questions

Big-O, arrays, hashing, trees, graphs, DP, coding-round patterns

17 questions · O(n log n) · updated November 2026

Practise these as flashcards. One or two lines each; the ones you miss come back first.

Start free

Core questions

What is Big-O notation and why is it important?

Big-O notation describes how an algorithm's time or space requirements grow as the input size increases. It's important because it helps us compare and choose efficient algorithms, especially for large datasets.

How do you reverse a linked list?

I iterate through the list, changing each node's next pointer to point to the previous node. At the end, the last node becomes the new head. This is an O(n) time, O(1) space operation.

What is a hash map and when would you use one?

A hash map is a data structure that stores key-value pairs and allows fast lookups, inserts, and deletes. I use it when I need to count elements, check for duplicates, or map values efficiently.

What is the difference between a stack and a queue?

A stack is Last-In-First-Out (LIFO), so the last element added is removed first. A queue is First-In-First-Out (FIFO), so the first element added is removed first.

Intermediate questions

Explain the sliding window technique and give an example.

The sliding window technique maintains a window of elements and moves it across the array or string to solve problems efficiently. For example, to find the maximum sum of k consecutive elements, I sum the first k, then slide the window by adding the next element and removing the first, updating the sum each time.

How does cycle detection in a linked list work?

I use two pointers: one moves one step at a time (slow), the other moves two steps (fast). If there's a cycle, they will eventually meet; if not, the fast pointer will reach the end. This is Floyd's algorithm and runs in O(n) time.

What are collisions in hash maps and how are they handled?

Collisions occur when two keys hash to the same bucket. They're handled by chaining (storing multiple items in a bucket, usually as a list) or open addressing (finding another bucket using a probing sequence).

Describe the difference between BFS and DFS in graphs.

BFS explores nodes level by level using a queue, making it ideal for shortest path in unweighted graphs. DFS explores as deep as possible using a stack or recursion, which is useful for connectivity and cycle detection.

What is a binary search and when would you use it?

Binary search finds an element or boundary in a sorted array by repeatedly dividing the search interval in half. I use it when the data is sorted and I need O(log n) search time.

How does a heap work and what are its use cases?

A heap is a binary tree where each parent node is smaller (min-heap) or larger (max-heap) than its children. It's used for priority queues, scheduling, and efficiently finding the minimum or maximum element.

Explain memoization versus tabulation in dynamic programming.

Memoization is a top-down approach where I cache results of recursive calls. Tabulation is a bottom-up approach where I fill a table iteratively. Both avoid redundant calculations, but tabulation is often more space-efficient and avoids recursion stack limits.

What is a monotonic stack and where is it used?

A monotonic stack maintains elements in increasing or decreasing order. It's used for problems like finding the next greater or smaller element in an array, which can be solved in O(n) time.

Senior questions

How would you optimize a brute-force solution using hash maps?

See the answer in the app, free

Describe how you would implement Dijkstra's algorithm for shortest paths.

See the answer in the app, free

How do you handle edge cases in coding interviews?

See the answer in the app, free

How would you run a coding interview for a candidate?

See the answer in the app, free

Explain how you would use binary search on the answer in an optimization problem.

See the answer in the app, free

More Developer fundamentals topics