Binary string
Anonymous User
3813

Given a binary string of length n convert it to 1. Number of operations that can be performed on string are n-1. In one operation: You can replace adjacent characters of a string by their XOR (or) their AND without changing order of remaining characters. O/P Yes if possible to convert string to 1 else No. (Binary strings consists only 0's and 1's)
Example 1100.
1 replace 2nd and 3rd character with their xor so-> 110.
2 replace 2nd and 3rd Character by their xor so-> 10.
3 replace 1st and 2nd character by xor so-> 1.
4 So o/p is Yes.
TC:
00000 O/P->NO
000111 O/P-> YES
0 O/P-> NO

Comments (2)