Not getting correct output in the question

Hey @Bhavya_Goel, the logic for viewing the right side is perfectly fine, however, you’re not taking the input in correct way.
In the question, it says that if the node is at index i, then the left and right nodes will be at 2i,2i+1 (following one based indexing here). This can be done easily using BFS technique.
I’ve changed the input taking function in your code you can check it here