Skip to content

Commit 9746ec1

Browse files
Merge pull request #2003 from CodingTestStudy2/최민지
[최민지] Day10
2 parents e7fd81b + 9428894 commit 9746ec1

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

‎leetcode3/최민지/3314.py‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Solution:
2+
def minBitwiseArray(self, nums: List[int]) -> List[int]:
3+
ans = []
4+
for n in nums:
5+
if n % 2 == 0:
6+
ans.append(-1)
7+
else:
8+
# 10 || 01 = 11
9+
# 100 || 101 = 101
10+
# 110 || 111 = 111
11+
for x in range(n):
12+
if (x | (x+1)) == n:
13+
ans.append(x)
14+
break
15+
return ans

0 commit comments

Comments
 (0)