You are given an integer \(N\).
We represent the number \(N\) as the sum of distinct numbers that are powers of \(2\).
Task
If we put these numbers in an array, your task is to find the maximum element in this array.
Example
Assumption:
\(N=10 \)
Approach:
\(10\) can be expressed as the sum of \([1,2,8]\) which are powers of \(2\) and the
maximum of these numbers is \(8\). Hence, the answer is \(8\).
Function description
Complete the function solve provided in the editor. This function takes the following one parameter and returns the required answer:
\(N\): the integer which is to be represented as the sum of powers of \(2\).
Input format
Note: This is the input format that you must use to provide custom input (available above the Compile and Test button).
The first line contains \(T\) denoting the number of test cases. \(T\) also specifies the number of times you have to run the solve function on a different set of inputs.
For each test case:
The first line contains the integer \(N\).
Output format
For each test case, print the answer in a new line.
Constraints
\(1 \leq T \leq 10\)
\(1 \leq N \leq 10^{6}\)
Code snippets (also called starter code/boilerplate code)
This question has code snippets for C, CPP, Java, and Python.