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
64 practiced
Implement longest_substring_k_distinct(s: str, k: int) in Python returning the length of the longest substring containing at most k distinct characters. Use an optimal sliding-window algorithm in O(n) time. Explain how you manage counts and when to shrink the window.
EasyTechnical
67 practiced
Given d = {'a':1, 'b':2, 'c':3}, show three idiomatic Python ways to iterate over keys and values to (a) print keys, (b) print values, and (c) print key-value pairs. Explain why modifying a dict while iterating over it is problematic and provide a safe approach to remove keys while iterating.
HardTechnical
55 practiced
Implement an algorithm to find the longest palindromic substring in a given input string. Explain the trade-offs between expanding-around-center (O(n^2)) and Manacher's algorithm (O(n)). Provide a working Python implementation for your chosen approach and explain why it meets the stated complexity.
MediumTechnical
64 practiced
Implement top_k_frequent(nums: List[int], k: int) in Python that returns the k most frequent elements. Use a dictionary for counting and an efficient method to retrieve top k (heap or bucket sort). Describe time and space complexity and when to prefer each retrieval method.
MediumTechnical
54 practiced
Group anagrams: given a list of lowercase words like ['eat','tea','tan','ate','nat','bat'], group them into lists of anagrams. Implement group_anagrams(words: List[str]) -> List[List[str]] in Python and explain the time complexity. Discuss an alternative key representation to sorting each word.

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.