Search
⌘K

Leetcode 2546. Apply Bitwise Operations to Make Strings Equal

Determine whether you can transform binary string s into target by repeatedly picking indices i,j and replacing (s[i],s[j]) with (s[i] OR s[j], s[i] XOR s[j]); key observation: any string with at least one '1' can be transformed into any other string with at least one '1', while an all-zero string stays all-zero, so the answer is true iff s == target or both strings contain at least one '1'.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.