Skip to content

Commit 860084e

Browse files
committed
BitwiseTwo resolved
1 parent 0ef2460 commit 860084e

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/easy/BitwiseTwo.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package main
2+
3+
import "fmt"
4+
5+
func BitwiseTwo(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 string(s1[i]) == "1" && string(s2[i]) == "1" {
13+
result += string("1")
14+
} else {
15+
result += string("0")
16+
}
17+
}
18+
19+
return result
20+
}
21+
22+
func main() {
23+
24+
// Test cases
25+
result1 := BitwiseTwo([]string{"010111", "101101"})
26+
fmt.Println(result1)
27+
result2 := BitwiseTwo([]string{"110001", "111100"})
28+
fmt.Println(result2)
29+
}

0 commit comments

Comments
 (0)