Booking.com Phone interview question
Anonymous User
3108
Jul 16, 2021
Jul 16, 2021

There is list of hotels and they are given in below format:
{ hotel id, parent hotel id, no. of hotel}
mutlilevel hotel hierarchy exits in the system.
example:
[ { 3,0,14}
{0, null, 10}
{4,0,44}
{6, null, 7}
{10, 6, 13}
{7, 6, 17}
{2, null, 2}
{14, 2, 9}
{25, 14, 10}
{12, 2, 10}
{13, 0, 1}
{14, 2, 9}
]

Here null represent the top level of the hotel. We want to know top k hotel chains.
o/p: if k =2:
{(0,69), (2,56)}

Comments (9)