This commit is contained in:
2026-01-21 18:52:24 +08:00
parent 2797ee2b17
commit 04aa2ffc7d
2 changed files with 41 additions and 0 deletions

19
26/01/go/3315.go Normal file
View File

@@ -0,0 +1,19 @@
package A
func minBitwiseArray(nums []int) []int {
ans := make([]int, 0, len(nums))
for _, num := range nums {
if num == 2 {
ans = append(ans, -1)
continue
}
temp := num
t := 0
for temp&1 == 1 {
t++
temp >>= 1
}
ans = append(ans, num^(1<<(t-1)))
}
return ans
}