text: #include <stdio.h>
  #include <stdlib.h>
  #include <stdbool.h>
  
  struct ListNode {
      int val;
      struct ListNode *next;
  };
  
  static bool hasCycle(struct ListNode *head)
  {
      struct ListNode *fast = head;
      struct ListNode *slow = head;
      while (fast != NULL && fast->next != NULL) {
          slow = slow->next;
          fast = fast->next->next;
          if (fast == slow) {
              return true;
          }
      }
  
      return false;
  }
  
  int main(int argc, char **argv)
  {
      int i, count = argc - 1;
      struct ListNode *head = NULL, *p, *prev;
      for (i = 0; i < count; i++) {
          p = malloc(sizeof(*p));
          p->val = atoi(argv[i + 1]);
          p->next = NULL;
          if (head == NULL) {
              head = p;
          } else {
              prev->next = p;
          }
          prev = p;
      }
      p->next = head;
  
      printf("%s\n", hasCycle(head) ? "true" : "false");
      return 0;
  }
  