I wrote code in Java for this problem on SPOJ. My solution took time: 0.04 and memory: 4284M. When I was looking into the best solutoin records it was time: 0.02 and memory: 177M.
Can someone help me understand how can I achieve this efficiency in my code.
Thank you Garrett,
i am still trying to improve the time.
Problem: Problem TEST
Best Results: Sphere Online Judge (SPOJ)
1MB solution is for C lang; for Java it is 177M