InterviewStack.io LogoInterviewStack.io

Core Data Structures Questions

Fundamental built in data structures used in everyday programming and coding interviews, focusing on lists, strings, and dictionaries. For lists cover indexing, slicing, iteration, common mutation operations such as append and extend, common algorithms such as sorting and reversing, and memory and performance implications. For strings cover indexing, slicing, common methods such as split, join, strip, replace, and approaches to string manipulation and pattern processing. For dictionaries cover key value semantics, insertion and lookup, iteration patterns, methods for safe access, and using dictionaries as hash tables for counting and grouping. Candidates should also know the time complexity of common operations expressed in plain terms such as constant time, linear time, and quadratic time, and be able to choose the appropriate structure for a problem and reason about space and performance tradeoffs. Practice often includes implementation level manipulations, common interview problems such as two sum and frequency counting, and writing clear code using these structures.

HardTechnical
48 practiced
Given a predicate function f(x) that partitions a list into True/False groups, implement an in-place stable partition(arr, f) -> None that moves elements such that all True elements precede False elements while preserving relative order within each group. Aim for O(n log n) or better time and O(1) extra space if possible; discuss tradeoffs.
EasyTechnical
61 practiced
List common operations on lists, strings, and dictionaries (indexing, append, lookup, concatenation, split/join, iteration). For each, give the typical time complexity expressed in plain terms (constant, linear, quadratic) and a brief justification. Mention at least three operations for each structure and why complexity matters in ML preprocessing code.
EasyTechnical
92 practiced
Given a list of tokens (strings), implement a Python function count_frequencies(tokens: List[str]) -> Dict[str, int] that returns a dictionary mapping each token to its count. Show two different implementations: one using a plain dict and one using collections.Counter. Discuss time and space complexity and when Counter is preferable.
MediumTechnical
50 practiced
Implement a generator flatten(nested) that yields elements from an arbitrarily nested list like [1, [2, [3, 4], 5], 6] producing 1,2,3,4,5,6. Provide both recursive and iterative implementations and explain memory trade-offs for deep nesting.
MediumTechnical
46 practiced
Write a function merge_sorted(a: List[int], b: List[int]) -> List[int] that merges two sorted lists into a single sorted list using two pointers. Provide in-place strategies when possible, explain time and space complexity, and discuss when you might prefer to allocate a new list vs merge in-place for memory constraints.

Unlock Full Question Bank

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

Sign in to Continue

Join thousands of developers preparing for their dream job.