How to take input

please tell me sir how to take input and provide code

@sksumitkumardiwaker you have to build a tree from the level order traversal first .

public Node takeInput(Scanner s) {
Queue q = new LinkedList<>();
int data = s.nextInt();
Node node = new Node(data);
if(data != -1) {

        q.add(node);
        }
        while (!q.isEmpty()) {
            Node temp = q.poll();
            data = s.nextInt();
           
            if (data != -1) {
            	 temp.left = new Node(data);
                q.add(temp.left);
            }
            data = s.nextInt();
            
            if (data != -1) {
            	temp.right = new Node(data);
                q.add(temp.right);
            }
        }
        return node;
    }