Doubt regarding Circular Linked List problem

This is my code .

import java.util.*;
public class Main {
public static void main(String args[]) {

	LinkedList ll = new LinkedList() ;
	ll.removeLoop() ;
	ll.display() ;
}

}
class LinkedList{
private class Node{
int data ;
Node next ;
Node(int data){
this.data = data ;
}
}
Node head ;
Node curr ;
int size ;

LinkedList(){
	buildList() ;
}

private void buildList(){

	Scanner scan = new Scanner(System.in) ;
	HashMap<Integer,Node> map = new HashMap<>() ;
	int data = scan.nextInt() ;
	Node n1 = new Node(data) ;
	head = n1 ;
	curr = n1 ;
	size ++ ;
	map.put(head.data,head) ;
	int x = scan.nextInt() ;
	while(x != -1){
		
		if(!map.containsKey(x)){
			Node nn = new Node(x) ;
			curr.next = nn ;
			curr = nn ;
			map.put(curr.data,curr) ;
			size ++ ;
		}
		else{
			Node addr = map.get(x) ;
			curr.next = addr ;
			curr = curr.next ;
		}
		x = scan.nextInt() ;
	}
}

public void removeLoop(){

	Node slow = head ;
	Node fast = head ;

	while(true){
		slow = slow.next ;
		fast = fast.next.next ;
		if(slow == fast){
			break ;
		}
	}
	slow = head ;
	while(slow.next != fast.next){
		slow = slow.next ;
		fast = fast.next ;
	}

	fast.next = null ;
}

public void display(){

	Node temp = head ;
	while(temp != null){
		System.out.print(temp.data+" ") ;
		temp = temp.next ;
	}
}

}

But some test cases are failing . Can you tell me where did I go wrong in my logic .

@Lalit2142,
Input:
1 2 3 1 2 3 1 2 3 1 2 3 -1
Expected Output:
1 2 3
Your Output:
1

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.