← Booking Interview Insights

Booking·Software Engineer·Online Assessment (OA)·Intermediate

Intermediate
Jun 2026

Summary

Booking's online assessment for the SWE role was 90 minutes, three questions, pretty standard algo stuff plus one problem that felt more domain-specific to what they actually do. Nothing too brutal but the third question had enough moving parts to eat up time if you weren't careful.

Questions Asked (3)

Q1

Given an array of strings, group all anagrams together.

Algorithms & Data Structures
Author's notes

Classic.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the problem constraints (e.g., case sensitivity, empty strings, expected output format) and then propose a solution using a hash map where the key is a canonical representation of each anagram (e.g., sorted string or character count). Group strings by their key and return the grouped lists. Discuss time and space complexity and consider alternative approaches.

Pro tip: Mention that sorting each string to form the key takes O(k log k) per string, but using a character count key can reduce it to O(k) for strings with a small alphabet, showing awareness of optimization trade-offs.

1. Clarify requirements

Ask about input constraints: string length, character set, case sensitivity, and whether the output order matters. This ensures you handle edge cases correctly.

2. Choose a canonical key

Decide on a method to represent anagrams uniquely, such as sorting the characters or using a frequency count array. Explain why this key works.

3. Design the algorithm

Use a hash map to group strings by their key. Iterate through the array, compute the key for each string, and append the string to the corresponding list.

4. Analyze complexity

State the time and space complexity. For sorting approach: O(n * k log k) time, O(n * k) space. For counting approach: O(n * k) time, O(n * k) space.

5. Test with examples

Walk through a small example (e.g., ["eat", "tea", "tan", "ate", "nat", "bat"]) to demonstrate correctness and discuss edge cases like empty strings or duplicates.

Key Points to Mention

  • Hash map usage for grouping
  • Canonical key generation (sorted string or character count)
  • Time and space complexity analysis
  • Handling edge cases (empty strings, case sensitivity)
  • Alternative approaches and trade-offs
  • Potential follow-up: grouping anagrams in a stream or large dataset

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

Q2

Given a non-negative integer, return the maximum value you can get by swapping at most one pair of digits.

Algorithms & Data Structures
Author's notes

This one tripped me up more than it should have.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Convert the integer to a string or array of digits to easily manipulate positions. Scan from left to right to find the first digit that has a larger digit to its right, then swap it with the rightmost occurrence of the maximum such digit. If no such digit exists, the number is already maximal, so return it unchanged.

Pro tip: Clarify edge cases upfront, such as single-digit numbers or numbers with all identical digits, and mention that you'll handle them without unnecessary swaps. Also, discuss time and space complexity (O(n) time, O(n) space for digit array) to demonstrate thoroughness.

1. Understand the problem

Restate the problem: given a non-negative integer, you may swap at most one pair of digits to maximize its value. Confirm that you can choose not to swap if the number is already maximal.

2. Choose representation

Convert the integer to a string or list of characters/digits to allow easy indexing and swapping. Discuss trade-offs: string manipulation is simpler but may involve extra space.

3. Identify optimal swap

Traverse digits from left to right. For each position, find the maximum digit to its right; if that maximum is greater than the current digit, swap with the rightmost occurrence of that maximum and stop. This ensures the most significant digit is increased as much as possible.

4. Handle no-swap case

If no such pair is found (digits are non-increasing), return the original number unchanged. This covers cases like 54321 or 1111.

5. Analyze complexity and test

State time complexity O(n) and space O(n) for the digit array. Walk through examples: 2736 → 7236, 9973 → 9973, 115 → 511, 10 → 10.

Key Points to Mention

  • Greedy strategy: prioritize leftmost digit that can be increased.
  • Use rightmost occurrence of the maximum digit to minimize disruption to lower-order digits.
  • Edge cases: single-digit numbers, all digits same, already maximal numbers.
  • Time and space complexity: O(n) time, O(n) space (or O(1) if using integer arithmetic).
  • Alternative approaches: brute-force O(n^2) vs. optimal O(n) greedy.
  • Communication: explain reasoning clearly and test with examples.

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

Q3

Given positive and negative keyword lists, a list of hotel reviews each tied to a hotel ID, and an integer k, return the top-k hotel IDs ranked by total sentiment score (ties broken by smaller ID first).

Algorithms & Data StructuresProduct Analytics & Metrics
Author's notes

This is clearly a Booking-flavored problem and I kind of liked that.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, clarify the scoring rules: each positive keyword occurrence adds +1, each negative adds -1, and the total sentiment score per hotel is the sum across its reviews. Then, aggregate scores per hotel using a hash map, and select the top k hotels using a min-heap of size k (or sort all hotels) with tie-breaking by smaller ID first.

Pro tip: Mention that you would preprocess keywords into a hash set for O(1) lookups, and use a min-heap to achieve O(n log k) time, which is efficient for large datasets. Also, discuss how to handle ties by storing (score, hotel_id) in the heap and defining a custom comparator.

1. Clarify scoring rules

Confirm that each occurrence of a positive keyword adds +1 and each negative adds -1, and that scores are summed across all reviews for a hotel. Ask if multiple occurrences in one review count multiple times.

2. Preprocess keywords

Store positive and negative keywords in hash sets for O(1) lookup. Consider case sensitivity and tokenization (e.g., splitting on whitespace and punctuation).

3. Compute per-hotel scores

Iterate through each review, tokenize the text, and for each token check if it's in the positive or negative set, updating a running score. Accumulate the score into a hash map keyed by hotel ID.

4. Select top-k hotels

Use a min-heap of size k to keep the top k hotels by score, with tie-breaking by smaller ID first. Alternatively, sort all hotels by score descending and ID ascending, then take the first k.

5. Return result

Extract hotel IDs from the heap or sorted list and return them in the correct order (highest score first, then smallest ID).

Key Points to Mention

  • Time complexity: O(R * L + H log k) where R is number of reviews, L average review length, H number of hotels, using min-heap for top-k.
  • Space complexity: O(H + K) for the score map and heap, plus O(P+N) for keyword sets.
  • Tie-breaking: when scores are equal, smaller hotel ID comes first; ensure comparator handles this.
  • Edge cases: empty reviews, no keywords, k larger than number of hotels, negative scores.
  • Tokenization: split on whitespace and punctuation, consider lowercasing for case-insensitive matching.
  • Scalability: if data is huge, consider streaming reviews and updating scores incrementally, or using MapReduce.

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