using System;
public class ListNode {
public int val;
public ListNode next;
public ListNode(int x) { val = x; }
}
public class Program
{
public static void Main()
Console.WriteLine("Hello World");
public bool HasCycle(ListNode head) {
ListNode slow=head;
ListNode fast=head;
while(fast!=null && fast.next!=null)
slow=slow.next;
fast=fast.next.next;
if(slow==fast) return true;
return false;