One test case failed to pass

import java.util.*;
public class Main {
static Scanner scn=new Scanner(System.in);
public class Node{
int data;
Node left;
Node right;
}
private Node root;
public Main(){
this.root=construct();
}
private Node construct(){
int n=scn.nextInt();
if(n==-1){
return null;
}
Node nn=new Node();
nn.data=n;
LinkedList q=new LinkedList<>();
q.addLast(nn);
while(!q.isEmpty()){
Node rn=q.removeFirst();
n=scn.nextInt();
if(n!=-1){
Node lc=new Node();
lc.data=n;
rn.left=lc;
q.addLast(lc);
}
n=scn.nextInt();
if(n!=-1){
Node rc=new Node();
rc.data=n;
rn.right=rc;
q.addLast(rc);
}
}
return nn;

}
public void bottomView() {

	HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
	bottomView(this.root, map, 0);
	ArrayList<Integer> list = new ArrayList<Integer>(map.keySet());
	Collections.sort(list);
	for (int i = 0; i < list.size(); i++) {
		System.out.print(map.get(list.get(i))+" ");
	}
	System.out.println();
}

private void bottomView(Node root, HashMap<Integer, Integer> map, int vl) {
	// TODO Auto-generated method stub
	if (root == null) {
		return;
	}
	map.put(vl, root.data);
	bottomView(root.left, map, vl - 1);
	bottomView(root.right, map, vl + 1);

}
public static void main(String args[]) {
	Main m=new Main();
	m.bottomView();

}

}

@guptadev354,
You need to keep a check on the level of the node as well along with the horizontal distance.

Create an empty map where each key represents the relative horizontal distance of the node from the root node and value in the map maintains a pair containing node’s value and its level number.

Then do a pre-order traversal of the tree and if current level of a node is more than or equal to maximum level seen so far for the same horizontal distance as current node’s or current horizontal distance is seen for the first time, update the value and the level for current horizontal distance in the map.

For each node, recurse for its left subtree by decreasing horizontal distance and increasing level by 1 and recurse for right subtree by increasing both level and horizontal distance by 1.