Compute decayed power levels in a graph | Google Interview Question