Minute 75: a new parking rule. How many lines do you edit?
transcript
Minute 75 of the round. The interviewer adds one rule. How many of your lines do you have to edit?
Today's tariff. 20 rupees an hour for a bike. 40 for a car. 100 for a truck. Every started hour counts. A car stays 2 hours and 5 minutes? 3 hours. 120 rupees.
Now the mall wants the first 30 minutes free. On weekends. Where does that go?
An if inside leave? Now the lot knows about weekends. A weekend parking lot subclass? A whole lot, for one tariff. Or a new pricing class, passed to the lot. Nothing edited. The parking lot itself stays exactly as it was.
Here's why it works. The lot is given a pricing strategy. It just asks for a fee. Today, that's hourly pricing. Weekend rule? A small wrapper around hourly. Pricing classes compose.
Put what changes behind an interface. Tariffs change most. So a new tariff is a new class. Not an if in leave.
Full breakdown in the lecture.