STRQ - editorial

@shivama7 i haven’t read your solution completely but i guess the problem is that you have declared array c (size ~10^6) in main, make it global n check.

@johri21 my

[1] is giving TLE for the last subtask, can you advice me on how to optimize it


being a noob in programming, i implemented same algorithm…feeling proud of myself:P


@skysarthak try solving the question without the use of map stl.

Hi @skysarthak your AC solution CodeChef: Practical coding for everyone
.Now the problem with your code was, as the author asked you to take FAST IO, so applied that ,than WA came which was due to overflow.

1 Like

Can you please indent your code and write some comments so people can understand what your logic is!

Once you find the least index of both the characters in t3 and t4 respectively, you are linearly calculating the combination(i.e. for each query your computation is going t4-t3). Try to optimize it by precomputing the values. I hope I have understood your logic. Please correct me if you I have misunderstood anything.

Thank you. You have understood the logic correctly. Now its time for me to think how to optimize the approach.