InterviewStack.io LogoInterviewStack.io

Arrays, Strings, and Hashing Questions

Manipulating arrays and strings using the standard toolkit for entry-level coding-interview problems: two-pointer and sliding-window techniques, in-place modification (reversal, rotation, partitioning, deduplication), prefix sums, and hash-map or hash-set based techniques used to solve array or string problems in optimal time (frequency counting, lookup-based pairing such as two-sum, duplicate detection, grouping by a computed key such as anagram grouping). Hashing appears in this topic only as an applied technique for solving an array or string problem faster: how hash tables work internally (hash functions, collision resolution, load factor, resizing) and hash-based structures that are not array or string shaped (Bloom filters, HyperLogLog) belong to the separate hashing and hash tables topic, not this one. Covers the most frequent entry-level coding-interview problem shapes and the trade-offs between time, space, and readability. The default warm-up surface for any coding interview.

MediumTechnical
30 practiced

Given a list of possibly unhashable Python objects (for example dictionaries representing tokens), design an algorithm to deduplicate while preserving original order. Discuss time/space trade-offs and how you would adapt for extremely large datasets that must be processed in chunks or streaming.

MediumTechnical
37 practiced

You are given an array of n+1 integers where each value is between 1 and n (inclusive). Prove and implement an algorithm to find a duplicate value in O(n) time and O(1) extra space without modifying the array. (Hint: use cycle detection/floyd's algorithm treating indices as pointers.)

MediumTechnical
34 practiced

Write a function in Python to determine whether two strings are anagrams of each other in a Unicode-aware way. Consider normalization, casefolding, and handling of combining marks. Aim for O(n) time and O(k) extra space where k is the distinct character count. Discuss trade-offs between sorting-based and counting-based approaches when the alphabet is large.

EasyTechnical
35 practiced

Write a Python function to compute the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty string. Example: ['flower','flow','flight'] -> 'fl'. Discuss O(n * m) naive complexity and ways to optimize using vertical scanning or binary search.

EasyTechnical
64 practiced

Explain the difference between mutable and immutable string types in common languages (Python, Java, C++ std::string) and how that affects algorithm design for in-place vs copy-based operations, time complexity, and memory usage. Give examples where choosing one approach over the other matters in practice.

Unlock Full Question Bank

Get access to all Arrays, Strings, and Hashing interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.