Booking.com Interview Questions
- 0of 0 votes
AnswersGiven a list of hotelId, parentHotelId and a score retrieve the top k root parentHotelIds with the highest scores:
- dssd November 27, 2021 in Amsterdam
[{0, 1, 10}, {1, 2, 20}, {3, 4, 10}, {7, 8, 5}] K = 2
Result: [[2, 30], [4,10]]| Report Duplicate | Flag | PURGE
Booking.com Software Engineer Algorithm - 1of 1 vote
AnswersYou have three Arrays.
- monowar1993 June 14, 2019 in Netherlands for Android
A = {2, 5, 3, 2, 8,1}
B = {7, 9, 5, 2, 4, 10, 10}
C = {6, 7, 5, 5, 3, 7}
make an array from this three arrays which elements is present in at least two array.
This question was followed by instead of three arrays. If you have a list of array then what will be the solution? Also what will be the time complexity?| Report Duplicate | Flag | PURGE
Booking.com Android Engineer Java - 4of 4 votes
AnswersWrite algorithm for java grep command for word matching in the following context.Given a file containing n words.Given a word w and a number k.Find k words in the file occuring before occurence of w.Assume that the average word size is m in the file
- prashant.tah September 12, 2017 in India
eg.
aaa
bbb
ccc
booking
alpha
beta
gamma
for k=3 and w = booking
the output should be [aaa,bbb,ccc,booking]
similarly for k =2 and w = beta
output should be [booking,alpha,beta]
Assume that the file size can grow very large
and try to get solution with space complexity lesser than O(n)
I suggessted solution for iterating through file until the word w is found and maintaiining a queue of size K
The time complexity of my solution was O(nm)
and space complexity was O(k) .Any answers to improve the time and space complexity
Apparently they were looking for a better implementation of grep| Report Duplicate | Flag | PURGE
Booking.com Software Developer Algorithm - 0of 0 votes
AnswersConsider an N*N game board, with a black and white pieces that can be placed on it. You are given a board with placed pieces around it in a random spots.
You need to implement a function that determines if a piece (black or white) is captured on a given coordination (x, y).
A piece is defined as captured by the following rules:
1. If all sides (up, down, left & right) contains an opposite piece that surrounds/blocking it.
2. If some of the sides are blocked (for example, right and down) and the other ones are out of bound (OOB defined for coords: x: <= 0, y: <= 0) it's considered as blocked.
3. If one of the sides is empty, it's free.
4. If one of the sides contains the same piece type, and that piece is not captured (by the rules above), it's free.
5. Note that pieces may be captured in a clustered way (related to #4).
For example, consider the following coordinates:
coord(1,1) = B
coord(1,2) = W
coord(2,1) = WX | 1 | 2 1 | B | W 2 | W |
For the given coordination 1,1 the result would be `captured` (true).
Another example, consider the following coordinates:
coord(2,2) = W
coord(2,3) = W
coord(3,1) = W
coord(3,2) = B
coord(3,3) = B
coord(3,4) = W
coord(4,2) = W
coords(4,3) = WX | 1 | 2 | 3 | 4 | 5 | 2 | E | W | W | W | E 3 | W | B | B | B | W 4 | E | W | W | W | E
For the given coordination 3,2 (or 3,3) the result would be `true` (captured).
If we would either remove one of the W coords (thus making it empty), or change it to be a B piece, the result would be `false` (not captured).
As basic primitive, you are provided with a function that translates coordination into its state:
- johanson1 September 06, 2017 in NetherlandsgetState (x, y) == Black, White, Out Of Bound, Empty
| Report Duplicate | Flag | PURGE
Booking.com Software Developer Algorithm - 4of 4 votes
AnswersGiven arrays for N (>= 2) users, each representing the IDs of hotels visited, find the common IDs of the hotels visited amongst the users.
- PraTrick April 26, 2017 in India
Input:
userA = { 2, 3, 1 }
userB = { 2, 5, 3 }
userC = { 7, 3, 1 }
Output:
{3}
Assumptions:
Arrays are unsorted.
Cases:
1) Each array consists of distinct hotel IDs
2) Each array may contain duplicate hotel IDs| Report Duplicate | Flag | PURGE
Booking.com Software Engineer / Developer - 2of 2 votes
AnswersProblem statement
- PraTrick April 10, 2017 in India
Given a set of hotels and its guests reviews, sort the hotels based on a list of words specified by a user. The criteria to sort the hotels should be how many times the words specified by the user is mentioned in the hotel reviews.
Input
The first line contains a space-separated set of words which we want to find mentions in the hotel reviews.
The second line contains one integer M, which is the number of reviews.
This is followed by M+M lines, which alternates an hotel ID and a review belonging to that hotel.
Output
A list of hotel IDs sorted, in descending order, by how many mentions they have of the words specified in the input. If the count is same, sort according to the hotel IDs.| Report Duplicate | Flag | PURGE
Booking.com Software Engineer / Developer - 3of 7 votes
AnswersConsider a hotel where the guest is checked in and check out. Find a day when the maximum number of guests stay in a hotel.
- itsvks February 01, 2017 in Netherlands
example:
Input :
[
{check-in : 1, check-out 4},
{check-in : 2, check-out 5},
{check-in : 10, check-out 12},
{check-in : 5, check-out 9},
{check-in : 5, check-out 12}
]
Output : 5| Report Duplicate | Flag | PURGE
Booking.com Software Engineer / Developer Algorithm - 2of 2 votes
AnswersGiven number N, Find the least number of perfect square number sum needed to get N.
- itsvks February 01, 2017 in Netherlands
Example :
n=5 (4+1) i.e. 2
n=7 (4+1+1+1) i.e. 4
n=12 (4+4+4) i.e 3
n=20 (16+4) i.e. 2| Report Duplicate | Flag | PURGE
Booking.com Software Engineer / Developer Algorithm - 0of 0 votes
AnswersGiven a stream of characters (e.g. acacabcatghhellomvnsdb) and a list of words (e.g. ["aca","cat","hello","world"] ) find and display count of each and every word once the stream ends.(Like : "aca" : 2 , "cat" : 1 , "hello" : 1 , "world" : 0 ).
- badebhaiyya April 16, 2016 in United States| Report Duplicate | Flag | PURGE
Booking.com Software Developer Algorithm - 0of 0 votes
AnswersDesign auto complete for booking.com
- Qasim November 12, 2015 in Netherlands| Report Duplicate | Flag | PURGE
Booking.com Software Developer System Design - 2of 2 votes
AnswersWrite a function to test if the given set of brackets are balanced or not. e.g. {{}}{)([][]
- Qasim November 12, 2015 in Netherlands| Report Duplicate | Flag | PURGE
Booking.com Software Developer Algorithm - 1of 1 vote
AnswersYou are building a small command-line application to calculate hotel availability for a city. Your application reads in two (2) data files, and outputs its answer to STDOUT.
- amusing October 06, 2015 in United States
Your application will read in:
· a list of hotels along with how many rooms each contains (in no particular order)
· a list of bookings that have been made (in no particular order)
Your application will then print the list of all hotels which have availability for check-in and check- out date range, if any.
Do not worry about whether a specific room is available in a hotel for the entire booking period without switching rooms: availability is defined as the hotel having at least one (1) available room for each night of the target stay, regardless of whether it's the same room from day to day.
Data Files
hotels.csv
# Name, Rooms
Westin, 10
Best Western, 20
Hilton, 10
...
bookings.csv
# Name, Checkin, Checkout
Hilton, 2015-04-02, 2015-04-03
Hilton, 2015-04-02, 2015-04-04
Westin, 2015-05-01, 2015-05-20| Report Duplicate | Flag | PURGE
Booking.com Software Engineer / Developer Algorithm - 2of 2 votes
AnswersThere's a very simple compression algorithm that takes subsequent characters and just emits how often they were seen.
- Phil September 08, 2015 in Netherland
Example:
abababaabbbaaaaa| Report Duplicate | Flag | PURGE
Booking.com Software Engineer Algorithm - 3of 3 votes
Answers$a = [3, 1, 4, 5, 19, 6];
$b = [14, 9, 22, 36, 8, 0, 64, 25];
# Some elements in the second array are squares.
- Phil September 08, 2015 in Netherland
# Print elements that have a square root existing in the first array.
# $b[1] = 9, it’s square root is 3 ($a[0])
# $b[3] = 36, it’s square root is 6 ($a[5])
# $b[7] = 25, it’s square root is 5 ($a[3])
# Result:
# 9
# 36
# 25| Report Duplicate | Flag | PURGE
Booking.com Software Engineer Algorithm - 2of 2 votes
AnswersA multiset or a bag is a collection of elements that can be repeated. Contrast with a set, where elements cannot be repeated.
- ersegun August 20, 2015 in Netherlands
Multisets can be intersected just like sets can be intersected.
Input :
A = [0,1,1,2,2,5]
B = [0,1,2,2,2,6]
Output :
A ∩ B = C = [0,1,2,2]
Input :
A = [0,1,1]
B = [0,1,2,3,4,5,6]
Output
A ∩ B = C = [0,1]
Write a function to find the intersection of two integer arrays in that way ?| Report Duplicate | Flag | PURGE
Booking.com Software Developer String Manipulation - 2of 2 votes
Answers"Smart substring"
- ersegun August 20, 2015 in Netherlands
Write a function that takes maximum 30 characters from a string but without cutting the words.
Full description:
"Featuring stylish rooms and moorings for recreation boats, Room Mate Aitana is a designer hotel built in 2013 on an island in the IJ River in Amsterdam."
First 30 characters:
"Featuring stylish rooms and mo"
Smarter approach (max 30 characters, no words are broken):
"Featuring stylish rooms and"| Report Duplicate | Flag | PURGE
Booking.com Software Developer String Manipulation - 0of 0 votes
Answerspublic class Node
- sg August 18, 2015 in United States
{
public Node[] Children;
public Node Right;
}
Each node represents an element of a tree and specifies a list of immediate children.
The 'Children' property lists all children (in order) but the 'Right' property is set to null.
Suppose you are given the root of a fully populated tree (i.e. a Node called RootNode). Write code to set the 'Right' property so that each node is linked to its right sibling.| Report Duplicate | Flag | PURGE
Booking.com SDE-2 - 0of 0 votes
AnswersWrite an itoa
- JSDUDE July 09, 2015 in United States| Report Duplicate | Flag | PURGE
Booking.com Software Developer Algorithm String Manipulation - 17of 21 votes
AnswersYou have the file with word at a single line.
- madeinindia March 24, 2014 in neitherland for perl backend
#input sample file
abactor
abaculus
abacus
Abadite
.
.
Zyrenian
#Output
******************************************************************a
*************b
**********************************c
**********************d
*******************************************************************************e
a) you have to count the character and create a histogram in alphabetical order.
b) now you have to produce a histogram with max 80 character in line in reference to max count
c) now same out based histrogram based on the character count| Report Duplicate | Flag | PURGE
Booking.com Software Engineer / Developer Perl - 2of 2 votes
AnswersGiven a list/array of names(String) sort them such that each name is followed by a name which starts with the last character of the previous name.
- anurag.11feb January 07, 2014 in Netherlands
# input
[
Luis
Hector
Selena
Emmanuel
Amish
]
# output:
[
Emmanuel
Luis
Selena
Amish
Hector
]| Report Duplicate | Flag | PURGE
Booking.com Developer Program Engineer Algorithm - 4of 4 votes
AnswersTwo tables. Country and City
- sunny smart June 16, 2013 in Netherlands
country --> countryid, country name
city --> countryid, city name
1. how do you get the countries that has no cities?
2. how do you get the countries that has less than 3 cities and also make sure the countries with no cities also show up.| Report Duplicate | Flag | PURGE
Booking.com None None Database SQL - 5of 5 votes
AnswersWhat is the difference between a class method and an instance method?
- Mauricio.Malf February 21, 2013 in Netherlands| Report Duplicate | Flag | PURGE
Booking.com Software Engineer / Developer Object Oriented Design - 3of 3 votes
AnswersHow do you remove repeated values from a INT array, returning the resultant array in the same order as original ?
- Mauricio.Malf February 20, 2013 in Netherlands| Report Duplicate | Flag | PURGE
Booking.com Software Engineer / Developer Algorithm