Finished implementing detecting cycles solution. Working for all local test cases.