@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
[1]: http://www.codechef.com/viewsolution/6307244
http://www.codechef.com/viewsolution/6245563
being a noob in programming, i implemented same algorithm…feeling proud of myself:P
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.
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.