Google | Phone Interview
Anonymous User
1291

Don't remember the question preceisely but ask in the comment I should be able to fill the blanks.

Question
A toll route contains lots of checkpoint,
Every time a car passes through a check point on toll route its car number, checkpoint name are recorded.
At the end of the day bill is calculated and is sent to the customer.
Assume the cost of traveling between two checkpoints is 1$ ( or there is a built in function) .
How will you compute the bill for each car ?
Follow up:
Since there are tons of cars and lots of check point. The information is not consolidated as it is coming from lots of checkpoints.
So information would be something like
CH1 ( Checkpoint 1) : List of cars passed through them
CH 2 : List of cars passed through them
CH n : List of cars passed through them

As the information is quite huge how will you construct the bill for each car.
assumption: The car journey is not spread across days.
Imagine : in a day car only passes through toll route once.

Solution Not accepted:
I was initally thinking to keep list of cars at each checkpoint in set and then for each car you can check which checkpoint it crossed last. But the interviewer ( as I remember ) was quite focused on the volume of information and not being able to load in memory .

Any suggestions?

Comments (5)