Solution to Linked List Cycle Problem.

public class Solution {
    public boolean hasCycle(ListNode head) {
        ListNode sp = head;
        ListNode fp = head;
        
        while(fp != null && fp.next != null) {
            fp = fp.next.next;
            sp = sp.next;
            
            if(fp == sp)
                return true;
        }
        
        return false;
    }
}