Can anyone help me with this question ?
my approach was to find greatest character from the current char and find their difference but it gave me WA.Can anyone guide me here?
@gear how can your solution be O(n) if it is brute force?I think you might be messing up the logic to reduce the complexity and hence are getting WA...Because using brute force to simply calculate the cost of the given string without even making any changes itself is O(n^2).
@Wasp actually my solution is just able to pass 1 test case of the last subtask...Hence even though its better than the brute force(since it passes only 3 cases), my solution passes just 1 more case...Moreover, the 2nd test case of the 2nd subtask still gave TLE...