PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Booking

Solve three OA coding questions

Last updated: Mar 29, 2026

Quick Overview

This 90-minute assessment evaluates algorithmic problem-solving skills including string manipulation and grouping for anagram detection, digit-level reasoning for one-swap maximization, and text tokenization with aggregation and ranking for sentiment-based scoring.

  • medium
  • Booking
  • Coding & Algorithms
  • Software Engineer

Solve three OA coding questions

Company: Booking

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Take-home Project

You are given a 90-minute online assessment containing **three coding questions**. Implement solutions for all questions. --- ## Question 1: Group strings that are anagrams Given an array of strings `strs`, group the strings into lists where each list contains strings that are anagrams of each other. ### Input - `strs`: array of lowercase strings (may include duplicates) ### Output - A list of groups (each group is a list of strings). Order of groups and order within a group do not matter. ### Constraints (typical) - `1 <= len(strs) <= 10^4` - `0 <= len(strs[i]) <= 100` --- ## Question 2: Maximize an integer by swapping two digits at most once Given a non-negative integer `num`, you may swap **at most one pair** of its digits (or perform no swap). Return the **maximum value** you can obtain. ### Input - `num`: non-negative integer ### Output - Maximum integer achievable after at most one swap ### Constraints (typical) - `0 <= num <= 10^8` --- ## Question 3: Rank hotels by review sentiment and return top-k You are given: - A set of **positive keywords** and **negative keywords**. - A list of hotel reviews, each associated with a `hotel_id`. - An integer `k`. Compute each hotel’s total sentiment score by scanning all its reviews. ### Scoring rules - Tokenize each review into words by splitting on non-letter characters (punctuation and symbols are separators). - Comparison is **case-insensitive**. - For every word occurrence: - If the word is in the positive set: **+1** - If the word is in the negative set: **-1** - Otherwise: **0** - A hotel’s total score is the sum across all its reviews. ### Task Return the **top `k` hotel IDs** ranked by: 1. Higher total score first 2. If tied, smaller `hotel_id` first ### Input (one reasonable spec) - `positive_keywords`: string or list of words - `negative_keywords`: string or list of words - `hotel_ids`: array of integers, parallel to `reviews` - `reviews`: array of strings - `k`: integer ### Output - Array of `k` hotel IDs in sorted ranking order ### Constraints (typical) - `1 <= len(reviews) == len(hotel_ids) <= 10^5` - Total review text length up to ~`10^6` - `1 <= k <= number_of_distinct_hotels` ### Notes - If a hotel has multiple reviews, aggregate them. - If there are fewer than `k` hotels (in some variants), return all hotels sorted by the same rule.

Quick Answer: This 90-minute assessment evaluates algorithmic problem-solving skills including string manipulation and grouping for anagram detection, digit-level reasoning for one-swap maximization, and text tokenization with aggregation and ranking for sentiment-based scoring.

Related Interview Questions

  • Match Bookings to Payments - Booking (medium)
Booking logo
Booking
Nov 2, 2025, 12:00 AM
Software Engineer
Take-home Project
Coding & Algorithms
13
0

You are given a 90-minute online assessment containing three coding questions. Implement solutions for all questions.

Question 1: Group strings that are anagrams

Given an array of strings strs, group the strings into lists where each list contains strings that are anagrams of each other.

Input

  • strs : array of lowercase strings (may include duplicates)

Output

  • A list of groups (each group is a list of strings). Order of groups and order within a group do not matter.

Constraints (typical)

  • 1 <= len(strs) <= 10^4
  • 0 <= len(strs[i]) <= 100

Question 2: Maximize an integer by swapping two digits at most once

Given a non-negative integer num, you may swap at most one pair of its digits (or perform no swap). Return the maximum value you can obtain.

Input

  • num : non-negative integer

Output

  • Maximum integer achievable after at most one swap

Constraints (typical)

  • 0 <= num <= 10^8

Question 3: Rank hotels by review sentiment and return top-k

You are given:

  • A set of positive keywords and negative keywords .
  • A list of hotel reviews, each associated with a hotel_id .
  • An integer k .

Compute each hotel’s total sentiment score by scanning all its reviews.

Scoring rules

  • Tokenize each review into words by splitting on non-letter characters (punctuation and symbols are separators).
  • Comparison is case-insensitive .
  • For every word occurrence:
    • If the word is in the positive set: +1
    • If the word is in the negative set: -1
    • Otherwise: 0
  • A hotel’s total score is the sum across all its reviews.

Task

Return the top k hotel IDs ranked by:

  1. Higher total score first
  2. If tied, smaller hotel_id first

Input (one reasonable spec)

  • positive_keywords : string or list of words
  • negative_keywords : string or list of words
  • hotel_ids : array of integers, parallel to reviews
  • reviews : array of strings
  • k : integer

Output

  • Array of k hotel IDs in sorted ranking order

Constraints (typical)

  • 1 <= len(reviews) == len(hotel_ids) <= 10^5
  • Total review text length up to ~ 10^6
  • 1 <= k <= number_of_distinct_hotels

Notes

  • If a hotel has multiple reviews, aggregate them.
  • If there are fewer than k hotels (in some variants), return all hotels sorted by the same rule.

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Booking•More Software Engineer•Booking Software Engineer•Booking Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.