3605. Construct the Minimum Bitwise Array I
My accepted Python solution to LeetCode problem 3605, Construct the Minimum Bitwise Array I, running in 127ms.
- Difficulty: Easy
- Python
- Runtime 127ms
- Memory 17.5MB
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
Python
Accepted on LeetCode — runtime 127ms, memory 17.5MB, accepted 2026-01-01.
class Solution:
def minBitwiseArray(self, nums: List[int]) -> List[int]:
result = []
for num in nums:
found = False
for ans in range(num + 1):
if (ans | (ans + 1)) == num:
result.append(ans)
found = True
break
if not found:
result.append(-1)
return result