Rippling SDE-2 Phone Screening (Reject)
Question Details
YOE: 6 years # Part 1 – Basic Implementation Problem Statement: We are given a list of drivers and the deliveries they are making. Implement a service to compute the total cost of all deliveri
Full Details
YOE: 6 years # Part 1 – Basic Implementation Problem Statement: We are given a list of drivers and the deliveries they are making. Implement a service to compute the total cost of all deliveries. The service should expose three methods: 1. addDriver(driverId) 2. addDelivery(startTime, endTime) 3. getTotalCost() Key Points: * getTotalCost() needed to run in optimized time. * I optimized by computing and maintaining the total cost at the time of adding the delivery (instead of recalculating each time getTotalCost() is called). Result: * The interviewer tested against custom test cases → all passed. * He confirmed my optimization approach was valid. # Part 2 – Payment Functionality New Requirements: Add two new functionalities: 1. payUpToTime(upToTime) → settle the delivery cost up to this time. 2. getCostToBePaid() → get the remaining delivery costs left after settling the payment. My Approach: * Did I mess up here? I suggested we store the intervals for each driver and when payUpTo is called, loop over the intervals, sum up the costs and mark intervals as paid up. I explicitly asked my interviewer that this loops over all entries and if i should think of a more optimal solution, to which they said this is fine and asked me to implement * Then:costToBePaid = totalCost - paidCost Result: * Tested with interviewer’s test cases → all worked as expected. Final Result: Got a reject. What should I have done differently here?