When you face a problem and decide to solve it, you must understand the problem well before you start looking for a solution. Where your incorrect understanding of the problem may be the reason for providing a correct solution to a different problem. Worse still, you will no longer suspect that you have understood the problem wrong, and you will fall into a vicious cycle of trying to debug correct code. So, read and understand the problem well before starting anything...**good luck** :)
It's funny that before I wrote this post, I was yelling at my computer for not being able to understand the error I was trying to fix. LOOOL