1) Turn off your computer
2) Get some paper, pencils, and erasers
3) play around with how YOU would do it, using only the above materials.
4) Once you think you know how to do it, try to explain it to a 10 year old child in such a way that THEY could do it.
Only when you have completed the above should you consider turning on your computer and writing a single line of
java.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors