Given a problem how to write a code?
Anoniem
Remember dont jump to write the code. Analyse the problem, see that it works, check the test cases. After that all state coding. Remember that it was an HR question and he just wants to know your approach towards that problem.