Linear array with parent at i = 0 and children at 2i+1 and 2i+2
Find out all siblings of the person X. Return the sorted list of siblings.
If no siblings then return -1.
Example:
arr = 1,2,3,4,5,6
X = 5
Output: 4,6
Explanation : 2,3 are children of 1.
4,5 are children of 2.
6 are children of 3.
Here get children of 2 and 3 (because 3 is sibling of 2)
So siblings of 5 are 4,6.
What is the correct way to solve this program.
2i+1
and2i+2
.