Bloomberg telephone screen.
Summary
I had a telephone screen with Bloomberg where I was asked to design a data structure for a horse race with specific add and get methods.
Full Experience
Design data structure for a horse race, where we will have two methods.
add(string horseName, int checkpoint)
Updates the position of the horse. This method will be called for all the checkpoints horse crosses. Checkpoints are in increasing order.
get()
Return name of the horses, one with the highest checkpoint first When two horses are at the same checkpoint, print horses in the order which reached that checkpoint first.
Example.
Input.
["HorseRace","add","add","get","add","get","add","get"]
[[],["A",1],["B",1],[],["C",1],[],["B",2],[]]
Output.
[null,null,null,["A","B"],null,["A","B","C"],null,["B","A","C"]]
Interview Questions (1)
Design data structure for a horse race, where we will have two methods.
add(string horseName, int checkpoint)
Updates the position of the horse. This method will be called for all the checkpoints horse crosses. Checkpoints are in increasing order.
get()
Return name of the horses, one with the highest checkpoint first When two horses are at the same checkpoint, print horses in the order which reached that checkpoint first.
Example.
Input.
["HorseRace","add","add","get","add","get","add","get"]
[[],["A",1],["B",1],[],["C",1],[],["B",2],[]]
Output.
[null,null,null,["A","B"],null,["A","B","C"],null,["B","A","C"]]