Company: Moneyview
Difficulty: medium
Last Number from Completely Filled Levels Problem Description You are given a list A of N non-negative integers. Build an almost complete binary tree from them and print the last number of every level that is completely filled. An almost complete binary tree is built like this: Nodes are inserted level by level, from the top level downwards. Within a level, nodes are placed left to right with no gaps (the nodes are left justified). Every level except possibly the deepest one is completely filled. Level 1 holds at most 1 node, level 2 holds at most 2 nodes, level 3 holds at most 4 nodes, and in general level k holds at most 2^(k-1) nodes. A level is completely filled when it holds exactly that many nodes. Print the last number of each completely filled level, in top-to-bottom level order. Input Format The first line contains a single integer N , the number of elements in the list A . The second line contains N integers separated by single spaces, the elements of A in the order they are