Consider 189979 when your right pointer is initially at the last 9, what your code is doing is removing digits from the start one by one, but that would bring you to “79”, where nothing can be done.
Optimal answer would be two use two consecutive 9’s as pivot remove pre / post occurring characters one by one and the finally the two 9’s.
Hey,i got the same question and ended up wasting a lot of time thinking since it is a 50pts question there has to be an easy way to solve,i eventually moved on but i am extremely curious about the solution.Can you please share the link of the code or even a brief explanation.Thank you!
I think there is no trichy way to solve. But i think you can recure and memoization for the pair i,j which is index and for every index check min distance from one of the vendor finally return the value of i,j which is maximum from all
But due to any some minor mistake i’m found some wrong . I’m getting right in most of but still wrong in some. But at last your code is going to fail so i’m unhappy with this problem as 50. I think it will be hard for those who get this question to clear round . Or they will allow some of the place for this problem set? I dont know if anyone of you know then please clera that doubt
right. Isn’t it really easy for some people because if there exists 99 or the string length is 1, there’s an answer. I couldn’t figure it out, but many could have, easily.