See more
Take a piece of paper and a pencil and try to think. In this way, you will probably find the solution, but for sure you will develop algorithmic thinkin…
… I recommend you to work the first 250 most solved problem on SPOJ. Solve them in that exact order. And think of the solution for at least one hour.