Add solution to 'Detecting Cycles'