← Booking.com Interview Insights

Booking.com·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
May 2026Remote

Summary

Booking.com coding screen, pretty much just the classic group anagrams problem. Nothing too wild but it's the kind of question that feels easy until you're actually writing it out under pressure.

Questions Asked (1)

Q1

Given an array of strings, group all anagrams together and return the groups in any order.

Algorithms & Data Structures
Author's notes

I knew the sorted-key hashmap approach pretty much immediately, sort each string, use it as a key, bucket the originals under it.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Use a hash map to group strings by a canonical key that is identical for all anagrams. For each string, compute the key (e.g., sorted characters or character count signature) and append the string to the corresponding group. Finally, return the groups as a list of lists.

Pro tip: Discuss the trade-offs between sorting each string (O(n * k log k)) and using a character count key (O(n * k)), where n is the number of strings and k is the maximum length. Mention that the count-based approach can be more efficient for long strings with small alphabets, but sorting is simpler and often fast enough.

1. Clarify and Confirm

Ask clarifying questions: Are all strings lowercase? Can the input be empty? Should the output groups be sorted? Confirm that anagrams are case-sensitive and that the order of groups and within groups does not matter.

2. Choose a Canonical Key

Decide on a key that uniquely identifies anagrams. Common choices: sorted string (e.g., 'eat' -> 'aet') or a character count signature (e.g., 'a1e1t1'). Explain the trade-offs.

3. Group with Hash Map

Iterate through the array, compute the key for each string, and use a hash map to map the key to a list of strings. Append the current string to the list for its key.

4. Return Groups

After processing all strings, return the values of the hash map as a list of lists. The order of groups is arbitrary.

5. Analyze Complexity

State the time and space complexity. For sorting approach: O(n * k log k) time, O(n * k) space. For count approach: O(n * k) time, O(n * k) space. Mention that k is the max string length.

Key Points to Mention

  • Hash map for grouping by canonical key
  • Sorted string as key: simple but O(k log k) per string
  • Character count array as key: O(k) per string, but need to convert to a hashable format (e.g., tuple or string)
  • Time complexity: O(n * k log k) vs O(n * k)
  • Space complexity: O(n * k) to store all strings
  • Edge cases: empty input, strings of different lengths, Unicode characters

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.