text: https://github.com/Yashwanth-Chennu
  
  Problem Statement:https://www.hackerrank.com/challenges/detect-whether-a-linked-list-contains-a-cycle/problem
  
  Solution: 
  #include <bits/stdc++.h>
  
  using namespace std;
  
  class SinglyLinkedListNode {
      public:
          int data;
          SinglyLinkedListNode *next;
  
          SinglyLinkedListNode(int node_data) {
              this->data = node_data;
              this->next = nullptr;
          }
  };
  
  class SinglyLinkedList {
      public:
          SinglyLinkedListNode *head;
          SinglyLinkedListNode *tail;
  
          SinglyLinkedList() {
              this->head = nullptr;
              this->tail = nullptr;
          }
  
          void insert_node(int node_data) {
              SinglyLinkedListNode* node = new SinglyLinkedListNode(node_data);
  
              if (!this->head) {
                  this->head = node;
              } else {
                  this->tail->next = node;
              }
  
              this->tail = node;
          }
  };
  
  void print_singly_linked_list(SinglyLinkedListNode* node, string sep, ofstream& fout) {
      while (node) {
          fout << node->data;
  
          node = node->next;
  
          if (node) {
              fout << sep;
          }
      }
  }
  
  void free_singly_linked_list(SinglyLinkedListNode* node) {
      while (node) {
          SinglyLinkedListNode* temp = node;
          node = node->next;
  
          free(temp);
      }
  }
  
  // Complete the has_cycle function below.
  
  /*
   * For your reference:
   *
   * SinglyLinkedListNode {
   *     int data;
   *     SinglyLinkedListNode* next;
   * };
   *
   */
  bool has_cycle(SinglyLinkedListNode* head) {
      if(head == NULL)
          return 0;
          SinglyLinkedListNode* t = head, *h = head;
          while(h -> next!= NULL && h -> next -> next != NULL){
              t = t -> next;
              h = h -> next -> next;
              if(t  == h )
                  return 1;
          }   
          return 0;
  }
  
  int main()
  
     
  