Question: Coding language: C You are given a binary string. (string which contains O's and 1's), You have to perform several operations on this string, in

Coding language: C

You are given a binary string. (string which contains O's and 1's),

You have to perform several operations on this string, in one operation

You are given a binary string. (string which contains O's and 1's), You have to perform several operations on this string, in one operation choose a non-empty even length substring containing only O's or only 1's and remove it from the string. Your goal is to minimize the final length of the string after performing several operations.lt is possible that the final string may become empty, in that case print "KHALI" without quotes. And it can be proved that there is always an unique string with minimal length after performing the operations. Input: First line of input contains an intger T denoting number of testcases. Next Tlines of input contains a binary string S. Output: for each testcase print the required minimal string. Constraints: 1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

I have solved the question using stack which is the best possible way to solve this question in ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Algorithms Questions!