Tap here to switch tabs
Problem
Submissions

Problem: Apply Bitwise Operations to Make Strings Equal

Try to solve the Apply Bitwise Operations to Make Strings Equal problem.

Statement

You are given two 00 indexed binary strings s and target, both of length n. You can perform the following operation on s any number of times:

Choose two distinct indices i and j such that 0≤0 \leq i, j <n< n and i ≠\neq j. Simultaneously replace s[i] with (s[i] OR s[j]) and s[j] with (s[i] XOR s[j]).

Return true if it is possible to make the string s equal to target, or false otherwise.

Constraints:

  • n ==== s.length ==== target.length

  • 2≤2 \leq n ≤105\leq 10^5

  • s and target consist of only the digits 00 and 11.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Apply Bitwise Operations to Make Strings Equal

Try to solve the Apply Bitwise Operations to Make Strings Equal problem.

Statement

You are given two 00 indexed binary strings s and target, both of length n. You can perform the following operation on s any number of times:

Choose two distinct indices i and j such that 0≤0 \leq i, j <n< n and i ≠\neq j. Simultaneously replace s[i] with (s[i] OR s[j]) and s[j] with (s[i] XOR s[j]).

Return true if it is possible to make the string s equal to target, or false otherwise.

Constraints:

  • n ==== s.length ==== target.length

  • 2≤2 \leq n ≤105\leq 10^5

  • s and target consist of only the digits 00 and 11.