As reported: Expedia SDE 2 round 3, DSA (Gurugram, 2025), implementation-heavy — the interviewer wanted to see coding style: from a list of hotels, filter those with continuous availability for the given check-in and check-out dates and display their prices. The data had to be modelled first, then the pricing logic written. Time ran out after a complex first approach was simplified while coding; the round's feedback was "no hire" (slow typing, too much discussion).
Room availability is given as rows [hotelId, night, price]: hotel hotelId has a room on night night (an integer day number) at price. A stay from checkIn to checkOut covers the nights checkIn, checkIn + 1, …, checkOut − 1.
Return [hotelId, totalPrice] for every hotel that has a room on every night of the stay, where totalPrice is the sum of those nights' prices. Sort by totalPrice ascending, then by hotelId ascending.
Example 1
rooms = [[1,10,100],[1,11,120],[1,12,90],
[2,10,80],[2,12,85],
[3,10,150],[3,11,60],[3,12,70]]
checkIn = 10, checkOut = 12
-> [[3,210],[1,220]]
Hotel 2 has no room on night 11.
Example 2
rooms = [[5,1,200],[6,1,150],[5,2,200]], checkIn = 1, checkOut = 3 -> [[5,400]]
Clarifications
- Each
(hotelId, night)pair appears at most once. - Rows outside the stay are ignored; hotels with no row inside the stay are not listed.
Constraints: 0 ≤ rooms.length ≤ 10^5; 1 ≤ hotelId ≤ 10^6; 0 ≤ night ≤ 10^5; 1 ≤ price ≤ 10^4; checkIn < checkOut.
Code runner format: one JSON value per line: rooms, checkIn, then checkOut. Implement availableHotels(rooms, checkIn, checkOut); the harness prints the list of [hotelId, totalPrice].