{"size": 317, "ext": "js", "max_stars_repo_path": "src/linkedLists/cycle.js", "max_stars_repo_name": "vramdhanie/dsa_drills", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/linkedLists/cycle.js", "max_issues_repo_name": "vramdhanie/dsa_drills", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/linkedLists/cycle.js", "max_forks_repo_name": "vramdhanie/dsa_drills", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 14.4090909091, "max_line_length": 32, "alphanum_fraction": 0.5394321767}
function cycle(list) {
  if (!list.head) {
    return false;
  }

  let fast = list.head.next;
  let slow = list.head;

  while (fast && fast != slow) {
    slow = slow.next;
    if (fast.next) {
      fast = fast.next.next;
    } else {
      fast = fast.next;
    }
  }

  return !!fast;
}

module.exports = cycle;
