Microsoft interview question

Pretty standard graph question testing recursion