Education + Jobs Hiring Website - 2025
1 like 0 dislike
2,181 views
by | 2,181 views

1 Answer

0 like 0 dislike
Link to my solution code : https://ideone.com/rpi8V4

The basic idea , is that a self destructing string should have equal number of ones and zeroes  , so check if the given input string has even length , if yes, then , find the number of zeroes that you need to convert to "1" (or vice-versa), to get a string which has 'x' zeroes and 'x' ones , where x = n/2(length of string :n) .

Hope it helps!
by Expert (145,060 points)