Computer Science, asked by humeranaaz0403, 8 months ago

Complement
You are given a binary string S. In a single operation, you can choose
two indices L and R such that 1 3L3R&N and complement the
characters between L and Rie SL, SL+1, SR By complement, we
mean change character 0 to 1 and vice-versa,
You task is to perform ATMOST one operation such that in final string
number of 1s is maximised. If there is no need to completement, i.e.
string contains all 1s, return -1. Else, return the two values denoting L
and R. If there are multiple solutions return the lexicographically
smallest pair of Land R
vinnuite​

Answers

Answered by roshanpriya521
0

Answer:

Complement

You are given a binary string S. In a single operation, you can choose

two indices L and R such that 1 3L3R&N and complement the

characters between L and Rie SL, SL+1, SR By complement, we

mean change character 0 to 1 and vice-versa,

You task is to perform ATMOST one operation such that in final string

number of 1s is maximised. If there is no need to completement, i.e.

string contains all 1s, return -1. Else, return the two values denoting L

and R. If there are multiple solutions return the lexicographically

smallest pair of Land R

vinnuite

Similar questions