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.

HardTechnical
70 practiced
Explain the Count-Min Sketch data structure: layout of the array of counters, update and query pseudocode, error bounds, and how to choose width and depth given memory and desired error epsilon/delta. Discuss application to counting high-frequency metrics in SRE systems and how sketches can be merged across workers.
HardSystem Design
100 practiced
Design an index for time-series data that supports fast range queries by time and tag filters (e.g., host=web01, service=auth). Consider using inverted indexes for tags, time-partitioned B-trees or LSM-trees, and segment metadata. Discuss read/write complexity, memory footprint, compaction costs, and why you would choose one approach in an SRE observability backend.
HardTechnical
146 practiced
Implement a data structure in Python that supports insert(val), delete(val), and get_random() in expected O(1) time. get_random should return a uniformly random element among current elements. Provide the implementation details, explain how to handle duplicates, and analyze complexity and memory usage.
HardTechnical
72 practiced
You must implement cross-region deduplication for alerts that may be generated in different regions within seconds. Constraints: eventual consistency, bounded memory, and minimal added latency. Propose data structures and algorithms (time-bucketed bloom filters, counting bloom, CRDT approaches) to deduplicate with acceptable false positives, and analyze complexity, network cost, and consistency trade-offs.
EasyTechnical
90 practiced
Explain why hash table operations are O(1) on average but can degrade to O(n) in the worst case. Give examples of pathological inputs, discuss the roles of load factor, hash function quality, and collision-resolution strategy, and relate it to SRE concerns such as high-cardinality metric keys and DoS via adversarial inputs.

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.