InterviewStack.io LogoInterviewStack.io

Data Structures and Complexity Questions

Comprehensive coverage of fundamental data structures, their operations, implementation trade offs, and algorithmic uses. Candidates should know arrays and strings including dynamic array amortized behavior and memory layout differences, linked lists, stacks, queues, hash tables and collision handling, sets, trees including binary search trees and balanced trees, tries, heaps as priority queues, and graph representations such as adjacency lists and adjacency matrices. Understand typical operations and costs for access, insertion, deletion, lookup, and traversal and be able to analyze asymptotic time and auxiliary space complexity using Big O notation including constant, logarithmic, linear, linearithmic, quadratic, and exponential classes as well as average case, worst case, and amortized behaviors. Be able to read code or pseudocode and derive time and space complexity, identify performance bottlenecks, and propose alternative data structures or algorithmic approaches to improve performance. Know common algorithmic patterns that interact with these structures such as traversal strategies, searching and sorting, two pointer and sliding window techniques, divide and conquer, recursion, dynamic programming, greedy methods, and priority processing, and when to combine structures for efficiency for example using a heap with a hash map for index tracking. Implementation focused skills include writing or partially implementing core operations, discussing language specific considerations such as contiguous versus non contiguous memory and pointer or manual memory management when applicable, and explaining space time trade offs and cache or memory behavior. Interview expectations vary by level from selecting and implementing appropriate structures for routine problems at junior levels to optimizing naive solutions, designing custom structures for constraints, and reasoning about amortized, average case, and concurrency implications at senior levels.

EasyTechnical
74 practiced
Implement a function to reverse a singly linked list in-place and return the new head. Provide Python code or clear pseudocode. Analyze time and space complexity and consider edge cases: empty list, single node, and very long lists (stack considerations).
HardTechnical
71 practiced
Design a streaming service that maintains the top-k scoring items over a sliding time window (e.g., last 24 hours). Items can receive score updates and expire when older than the window. Propose data structures/algorithms for efficient updates, top-k retrieval, and expirations at scale. Discuss memory complexity, update/query time, and how to shard across machines.
HardTechnical
94 practiced
You maintain a tokenizer implemented using a trie for longest-prefix matching on CPU, but you must port it to GPU for faster tokenization or batched tokenization. Propose data structures or hybrid approaches that provide fast longest-prefix lookup, compact memory footprint, and efficient serialization to GPU memory. Compare double-array trie, radix tree, perfect hash with fallback, and finite-state transducers (FST); analyze lookup complexity and memory trade-offs.
MediumTechnical
94 practiced
Implement topological sort for a directed acyclic graph using Kahn's algorithm (BFS) and provide the DFS-based algorithm as well. Provide code or pseudocode, analyze complexity, explain how you detect cycles (i.e., when topological ordering is impossible), and discuss use-cases in ML pipelines (scheduling the order of data transforms).
MediumSystem Design
69 practiced
Design an in-memory dataset index for training deep learning models that must support: (1) random access by sample index, (2) efficient minibatch sampling (random and stratified), (3) fast epoch shuffling, and (4) low CPU overhead to avoid GPU starvation. Describe data structures, memory layout (contiguous arrays, mmap, metadata), sharding, and trade-offs when the dataset is hundreds of GB and cannot fully fit into RAM.

Unlock Full Question Bank

Get access to hundreds of Data Structures and Complexity interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.