How to take given input and build level order tree

I am not able to take the given input as given in question
1 2 3 4 5 -1 6 -1 -1 -1 -1 -1 -1 level order and print the right view of a binary tree.
can you provide the code on how to take the given input as input and print the right view of a binary tree

see that given input is in level order

Here is my code: https://ide.codingblocks.com/s/237485

(1) you won’t be getting the size of the array, just the array straightaway
(2) your logic assumes a complete binary tree
(3) to create a binary tree from level order input, we can build this binary tree by maintaining a queue. Queue is used to maintain those nodes that are not yet processed.

Using a variable count to keep track of the number of children added for the current node.

First, create a root node, assign it as the current node. So starting from index 1 (index 0 is the root), as the count is 0, we add this node as left child of the current node. Increase count. If this node is not β€˜-1’, add it to the queue.

Moving to the next index, the count is 1, so we add this as right child of current node, reset count to 0 and update current node (by assigning the current node as the first element in the queue). If this node is not β€˜-1’, add it to the queue.

code for the logic: https://ide.codingblocks.com/s/61962

Hope i could help you, if yes, please mark the doubt as resolved