This site is dedicated to helping others learn how to solve problems by writing code. As I work through the solutions found in the TopCoder Arena, I'll post my solutions - complete with comments and a full description. My hope is that by reviewing the source code and the notes sections, you will gain an understanding of the approach I took in solving the problem.

Each solution will be posted first in Java, and then additional languages as time allows. However, in most cases, the language used doesn't really matter. None of the solutions require a deep understanding of the programming language itself. There are other sites that teach the ins and outs of programming languages. This site is focused on how to solve problems.

If you've never tried the TopCoder Arena, I highly recommend it. Visit http://www.topcoder.com. The arena can be found under the Challenges drop-down menu. I'll be focusing on the Single-Round-Matches (SRM). These matches are held roughly every week or two - however, you are free to practice with any of the past matches.

As per the TopCoder terms and conditions, I will not include the problem statement itself. Instead, I'll provide a link (i.e. SRM 144 DIV 1 - 300 points). You'll need to visit the TopCoder site to get the details.

Unless otherwise noted, each solution will have passed all of the test cases that are run by the TopCoder Arena upon submission.

I do not claim that these are the best solutions. They are certainly not the most compact. Coding for a competition requires a different style than coding for "the real world". Often the submissions that score the highest points are very quick and dirty - making them very difficult to learn from. In fact, since one phase of the match allows competitors to challenge other competitor's code - it is in the coder's best interest not to make their solution understandable. I'll strive to make my solutions as easy to understand as possible.

Each of these solutions represents my own original work. That being said, I'd like to acknowledge the TopCoder Match Editorials. The descriptions found there have been helpful on those occasions when I needed a hint to get me moving in the right direction. Feel free to link to this site, but please don't copy the code or notes without giving credit.

All solutions are now available on GitHub at https://github.com/pmonkelban/TopCodingSolutions

Finally, I encourage you to leave feedback if you have any questions, comments, or if you found anything particularly helpful.

Thank you,


  1. Hi to every single one, it’s truly a good for me to visit this web page, I love your content, they are very nice and it includes helpful Information. Check out our website Linkedlist Interview Questions for more TutorialCup. related info! I am truly pleased to read this website posts which carries lots of helpful data, thanks for providing these kinds of statistics.

  2. Really helpful down to the ground, happy to read such a useful post. I got a lot of information through it and I will surely keep it in my mind. Keep sharing. If you are looking for some useful data and information regarding alteryx certification then visit Analytics Fun.