Bear and Steady Gene

  • + 0 comments

    As mentioned in the editorial, idea is, except the "sub string" to be removed, rest of the string state should be steady (i.e each charecter count less than n/4). The string is not steady due to fact that, one or many of ACTG letter is more than n/4.

    Solution is - Keep removing letters from original string till you get a string where state is steady. i.e the charecters count is less than n/4.

    In the solution, "j" counter in while loop keeps removing charecters (by reducing the count).

    During this removal, we might have removed few necessary charecters which are still needed. This charecter is added back at the end of for loop, to get the optimal solution.