Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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
Step: 1
I have solved the question using stack which is the best possible way to solve this question in ...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started