Microsoft Interview Question

Easy math question and graph traversal.