How will i build tree from given data? since no of nodes is not given?

i have tried but not getting teat cases passed

See the explanation figure the node are inserted in a pattern first root then left then right. Similarly on getting -1 return back to root node. So you can apply a check for -1 if yes then return to the last node.

For this type of question just think of simple approach. Rather it be top,left,right or bottom.
Just traverse the tree level wise either using queue or recursively. Just use a map where it stores the node you visit.
For bottom view.Think of vertical ordering of nodes.Considering root at index 0 and left as -1 and right as +1. Update the value in the map if you get another value for the same map. Because the last updated value is the bottom level nodes value which are visible from the bottom.

You can see this code for reference.The code is well commented for easier understanding.