Life, the Universe, and Everything
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.