Uber lld round

Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2025-08-05Added By Anonymous
Source: Link

Company: Uber
Role: unknown
Interview Stage: Onsite
Location: unknown
Year: unknown

Original Post Content:

ROUND 2

I recently interviewed with Uber and encountered the following question during the Low-Level Design (LLD) round. Prior to starting, I explicitly clarified whether the question was a data structure problem or an LLD problem. The interviewer confirmed that it was a data structure-focused question.

Question: Build a reservation system for a predefined set of conference rooms given as a list of room Ids [‘roomA’, roomB’...]. It should have a method like scheduleMeeting(startTime, endTime) should return a reservation identifier (including roomId) and reserve it or an error if no rooms are available.

// conference room are predefined
// room ids : string

Based on that, I proceeded with the following solution. However, I received a rejection after this round.

I would really appreciate it if someone could help me understand what might have gone wrong—whether it was an issue with the approach, communication, or alignment with expectations. This will help me improve for future opportunities.

Round 1 : Alien dictionery
Verdict - strong hire.

public class Solution {
private final Map<String, TreeMap<Integer, Interval>> map;

private int reservationCounter;

static class Interval {
int startTime;
int endTime;
String reservationId;
Interval(int s, int e, String id) {
this.startTime = s;
this.endTime = e;
this.reservati id;
}
}


public Solution(List<String> roomIds) {
map = new HashMap<>();
reservati 0;

for(String roomId: roomIds) {
map.put(roomId, new TreeMap<>());
}
}

public String scheduleMeeting(int startTime, int endTime) {
if(startTime >= endTime) {
throw new IllegalArgumentException("Start time is greater than end time");
}

for(String roomId: map.keySet()) {
TreeMap<Integer, Interval> treeMap = map.get(roomId);
Map.Entry<Integer, Interval> floor = treeMap.floorEntry(startTime);

Map.Entry<Integer, Interval> ceil = treeMap.ceilingEntry(endTime);
boolean isAllowed = false;
if(floor != null && floor.getValue().endTime > startTime) {
isAllowed= true;
}
if(ceil != null && ceil.getKey() < endTime) {
isAllowed = true;
}

if(!isAllowed) {
String reservati generateReservation(roomId);;
treeMap.put(startTime, new Interval(startTime, endTime, reservationId));
return bookingDetails(roomId, reservationId);
}
// if(isAvilable(map.get(roomId), startTime, endTime)) {
// String reservati generateReservation(roomId);
// map.get(roomId).add(new Interval(startTime, endTime, reservationId));
// return bookingDetails(roomId, reservationId);
// }
}

return "No rooms are available";
}



private String generateReservation(String roomId) {
return String.valueOf(++reservationCounter);
}

private boolean isAvilable(List<Interval> bookings, int startTime, int endTime) {
for(Interval interval: bookings) {
if(interval.endTime > startTime && interval.startTime < endTime) {
return false;
}
}
return true;
}

private static String bookingDetails(String roomId, String reservationId) {
return "roomId - " + roomId + "\t" + "reservationId\t" + reservationId;
}

public static void main(String[] args) {
Solution solution = new Solution(Arrays.asList("1"));

System.out.println(solution.scheduleMeeting(10, 15));
System.out.println(solution.scheduleMeeting(11, 12));
System.out.println(solution.scheduleMeeting(5, 11));
System.out.println(solution.scheduleMeeting(12, 18));
}
}
Comments