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.

EasyTechnical
0 practiced
Write a Python function that safely updates a dictionary of counters with increments from another dictionary, but only for keys that already exist in the target (i.e., ignore new keys). The function should be efficient for large dicts. Provide code and complexity reasoning.
HardTechnical
0 practiced
Design a data structure that supports insert(x), delete(x), and get_random() (returns a random element from current elements) each in average O(1) time. Implement it in Python using core data structures and explain how you maintain indices for O(1) deletions.
EasyTechnical
0 practiced
You're iterating over a Python dictionary and need to remove keys whose value equals 0. Explain why mutating a dict while iterating is dangerous and implement a safe function that removes those keys in a memory-efficient manner. Provide code and complexity analysis.
EasyTechnical
0 practiced
Explain common iteration patterns over dictionaries in Python (keys(), values(), items()) and when each is appropriate. Discuss the memory implications of list(dict.items()) vs iterating directly and how that matters when processing large datasets.
HardTechnical
0 practiced
Flatten a nested dictionary into a list of dotted paths for keys. For example: {'a': {'b': 1, 'c': {'d':2}}, 'e': 3} -> ['a.b', 'a.c.d', 'e']. Implement a Python function that yields paths as it walks the structure and handles deep nesting without recursion depth issues.

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.