Powers of 2
Problem Overview
- Determine for each integer in an array whether it is a power of 2, producing a binary result array.
- Input: arr of n integers (1 ≤ n ≤ 100, 0 ≤ arr[i] ≤ 5×10^7); Output: int[n] with 1 if arr[i] is a power of 2, else 0.
- Relevant to systems and data tasks where powers of two matter in memory or scaling contexts.
- From Oracle interviews, this coding interview problem is a common interview question.
Example
Unlock to view complete problem details
and practice with sample input/output
Was this article helpful?
View Test Cases & Run Code requires membership
Input Variables
Execution Result:
