public ListNode detectCycle(ListNode head) {
        ListNode oneStep = head;
        ListNode twoStep = head;

        while(oneStep != null && twoStep != null &&  twoStep.next != null){
            oneStep = oneStep.next;
            twoStep = twoStep.next.next;
            if(oneStep ==twoStep)
                break;
        }

        if(oneStep == null || twoStep == null || twoStep.next == null)
            return null;
        oneStep = head;
        while(oneStep != twoStep){
            twoStep = twoStep.next;
            oneStep= oneStep.next;
        }
        return oneStep;
    }