In the original version of the problem(BINSUBS) in January Lunchtime, we are given a simple Binary String and we have to find the minimum number of characters needed to be removed to make it a non decreasing string.
Try to solve the same problem with some minor modifications. Instead of 0’s and 1’s, the string can be made up of any of the 256 ASCII characters. The input string can have a maximum size n of 10^7. Find the minimum number of characters needed to be removed to make it a non decreasing string.
You can come up with any kind of complexity. Just make sure that the total number of operations are under 1e9.
I was actually able to come up with an algorithm that takes approximately 0.5e9 operations, whose time complexity was O(n*log2(256)). The bound might be a bit too tight. Ignore that if you want to. Just explore the various ways to do it; the learning around this problem was good for me.