Water Bottles
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
You start with numBottles full bottles of water. Drinking a full bottle leaves an empty one, and a shop trades numExchange empty bottles for one new full bottle. You can trade as many times as your empties allow.
Return the maximum number of bottles you can drink in total. Leftover empties that cannot be traded are simply kept.
Examples
Constraints
- 1 <= numBottles <= 100
- 2 <= numExchange <= 100
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.