Binary Tree Level Order Traversal II

Binary Tree Level Order Traversal II. Given a binary tree, return the bottom-up level order traversal of its node’s values.  (ie, from left to right, level by level from leaf to root).

OR

Given a binary tree, return the reverse level order traversal of its nodes’ values. (i.e, from left to right and from the last level to starting level).

Remove Duplicates From Sorted Array

Given a sorted array, we have to write a code to remove the duplicates in-place such that each element appear only once and return the new length.

For this problem, we don’t have to use extra space. As we have to remove duplicates in-place (In O(1)).

Note that we have to return the new length, make sure to change the original array as well in place

For example:

Input : { 1, 2, 2, 3, 4, 4, 5, 6, 6, 7 }

Output: 7

Our function should return length 7 with first seven elements of array are {1, 2, 3, 4, 5, 6, 7}. It doesn’t matter what you leave beyond the returned length