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.

MediumTechnical
0 practiced
Two Sum (medium): In Python, implement two_sum(nums, target) that returns a tuple of indices (i, j) where nums[i] + nums[j] == target. Assume exactly one valid pair exists and i != j. Aim for O(n) time and O(n) extra space using dictionaries. Provide code and explain the approach and complexity.
MediumTechnical
0 practiced
Implement nested_get(data, path, default=None) in Python where data may be a nested mixture of dicts and lists and path is a list like ['a', 0, 'b'] representing data['a'][0]['b']. Return default if any part of the path is missing. Provide a robust implementation and discuss error handling and performance.
EasyTechnical
0 practiced
In Python, implement a function safe_index(lst, index) that returns the element at position index and returns None when the index is out of range rather than raising an exception. The function must support negative indices (e.g. -1 for last element) and raise TypeError for non-integer index inputs. Show example calls and explain time complexity and memory implications for very large lists.
EasyTechnical
0 practiced
Describe string immutability in a language like Python. Explain how operations such as indexing (s[i]), slicing (s[a:b]), and methods like s.replace(old, new) behave with respect to object creation. Discuss time complexity of indexing and slicing, and explain why repeated concatenation in loops can be slow in production SRE scripts.
MediumTechnical
0 practiced
Implement find_top_k_errors(log_lines, k) in Python that returns the k most frequent error messages from an iterable of log lines. For moderate-size inputs you may use collections.Counter; explain how you'd change the approach for huge logs that don't fit in memory (e.g., external merge, map-reduce, sketch-based approximate top-k).

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.