text: /**
   * Definition for singly-linked list.
   * struct ListNode {
   *     int val;
   *     ListNode *next;
   *     ListNode(int x) : val(x), next(NULL) {}
   * };
   */
  class Solution {
  public:
      bool hasCycle(ListNode *head) {
          ListNode *slow_ptr{head}, *fast_ptr {head};
          while(slow_ptr and fast_ptr and fast_ptr->next){
              slow_ptr = slow_ptr->next;
              fast_ptr = fast_ptr->next->next;
              if(slow_ptr == fast_ptr)
                  return 1;
          }
          return 0;
      }
  };
  