Message on Whatsapp 8879355057 for DSA(OA + Interview) + Fullstack Dev Training + 1-1 Personalized Mentoring to get 10+LPA Job
1 like 0 dislike
1,117 views
by | 1,117 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 (109,130 points)