Skip to content

Practice Apply Bitwise Operations to Make Strings Equal

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#2546
LeetCode Problem

Apply Bitwise Operations to Make Strings Equal

Problem Statement

Given equal-length binary strings s and target, choose two different positions i and j of s. Using their values before the operation, simultaneously set position i to their bitwise OR and position j to their bitwise XOR. Repeat any number of times. Return whether s can become exactly target.

Source: Apply Bitwise Operations to Make Strings Equal on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
s = "1010", target = "0110"
Output
true

# Example 2

Input
s = "11", target = "00"
Output
false

Constraints

n == s.length == target.length
2 <= n <= 10^5
s and target consist of only the digits 0 and 1.

Related LeetCode Problems

Practice more problems similar to Apply Bitwise Operations to Make Strings Equal.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.