step 1: read the problem VERRRRY VERY carefully. take about 10-15 minutes to do so, even if you think you already understand everything. if you have already been reading for over 20 minutes and still do not understand the problem, ditch it and move on to another problem.
step 2: start thinking about a solution and WRITE IT DOWN. some people just immediately start coding and worry more about the syntax than the actual algorithm. you are smarter than that.
step 3: after you think you've got a solution and wrote it down, translate it into code. NOW you can start worrying about the syntax.
step 4: if it works, yay, you're welcome.
step 5: if it doesn't, choose one of the test cases and run through your code in your head, using the input you chose. fix wherever it went wrong.
hope this helps :)