Solve power jumps and graph tour | Microsoft Coding Question