Bridgewater Associates interview question

Breadth first search