Skip to content

Commit 0ef2460

Browse files
committed
BitwiseOne resolved
1 parent e216742 commit 0ef2460

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/easy/BitwiseOne.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package main
2+
3+
import "fmt"
4+
5+
func BitwiseOne(arr []string) string{
6+
s1 := arr[0]
7+
s2 := arr[1]
8+
9+
result := ""
10+
11+
for i := 0; i < len(s1); i++ {
12+
if s1[i] == s2[i] {
13+
result += string(s1[i])
14+
}else{
15+
result += string("1")
16+
}
17+
}
18+
19+
return result
20+
}
21+
22+
func main(){
23+
// Test cases
24+
result1 := BitwiseOne([]string{"001110", "100000"})
25+
fmt.Println(result1)
26+
result2 := BitwiseOne([]string{"110001", "111100"})
27+
fmt.Println(result2)
28+
}

0 commit comments

Comments
 (0)