Google Interview Question

It was a graph question of medium-hard difficulty level