Apply Bitwise Operations to Make Strings Equal
You are given two 0-indexed binary strings s and target of the same length n. You can do the following operation on s any number of times:
- Choose two different indices
iandjwhere0 <= i, j < n. - Simultaneously, replace
s[i]with (s[i]ORs[j]) ands[j]with (s[i]XORs[j]).
Return true if you can make the string s equal to target, or false otherwise.
Example 1
Input
s = "1010", target = "0110"Output
trueThe operations can transform s from "1010" into "0110", so s can be made equal to target.
Example 2
Input
s = "11", target = "00"Output
falseIt is not possible to make s equal to target with any number of operations.
Constraints
- n == s.length == target.length
- 2 <= n <= 10^5
- s and target consist of only the digits 0 and 1.