Blind 75 Array Questions
8 problems · Free practice
Array questions often become simpler when you change what you remember during a scan. A set answers whether a value has appeared; a map remembers its position or frequency. This group also includes string problems that use the same counting patterns. Start with membership and pair lookup, then work toward frequency grouping, prefix products, and sequences.
Practice arrays & hashing
Two Sum
EasyFind the indices of two different elements of an integer array whose sum equals a target. Assume exactly one pair exists; return the indices in either order.
Contains Duplicate
EasyDecide whether an integer array contains any repeated value. Return true when two different positions hold the same number.
Valid Anagram
EasyGiven two lowercase English strings, determine whether their character counts are identical. The order of the characters does not matter.
Group Anagrams
MediumPartition a list of lowercase English words so each group contains words with identical letter counts. Return the groups and words in any order.
Top K Frequent Elements
MediumReturn the k most frequent distinct integers in a nonempty array. Assume 1 ≤ k ≤ the number of distinct values and that the top-k set is unique. Order does not matter.
Product of Array Except Self
MediumFor each position, return the product of every array element except the one at that position. Use no division and aim for linear time. The array has at least two integers.
Encode and Decode Strings
MediumDesign encode(words) and decode(data) so any list of strings can be converted to one string and recovered exactly. Strings may be empty or contain your delimiter.
Longest Consecutive Sequence
MediumFind the length of the longest run of consecutive integer values present in an unsorted array. Values in the run need not occupy adjacent positions.
What to focus on
- Ask whether you need membership, a count, or an index before choosing your data structure.
- For prefix and suffix problems, state exactly which elements your running value includes.
- Test duplicates, negative values, and zero before claiming an approach works for every array.