leetcode-cpp
Though it initially started as just the solutions to the Online Judge at oj.leetcode.com, I am now including other sources as well including CTCI (cracking the coding interview). My motivation to do this is:
- keep my coding skills fresh
- prepare for technical interviews (those that I take and those that I give)
- find new and better ways to solve similar problems
- help budding developers learn from my solutions and even fork them
- help recuiters see my sample code
The source codes are my personal implementation (without external help in most cases) of all the problems in the best of the ability that I could solve them. If you want me to solve a particular (well defined) problem, email me at zakishaheen@me.com and I'll be glad to have a look at it.
The problems here are mostly those that could be done in the span of an interview which is typically less than an hour. Harder questions, such as those that come up in the Marathon matches at TopCoder or the harder ones at CodeChef are currently not the focus. Once I exhaust list of smaller questions (especially from leetcode), I will move on to other, harder questions.
Each source file comes with the question, one or more solutions and possible test cases. There are questions that require complex test harnesses which I will develop as I get time.
It would better if your browse the repo with the above references at hand.
Tips to answer these questions
- Practice, practice, practice.
- Start with the worst possible solution and build up.
- Its good to visualise a problem in terms of "constraints, ideas (with complexity of each), test cases and code" in that order. It helps to make a grid on the paper with these heading and working your way thru it. I learned that from www.hiredintech.com.
- Eventually, pace yourself.
- Redo problems after every few cycles. As you solve more and more questions, your 'axe' sharpens and you unlock better ways to do things than you knew before. so it means now you can solve the questions that you otherwise solved naively in a much better way.
- Read, read and read lot of 'books'. Not blogs, books! I recommend CLRS to begin with.
- Create your knowledge map. Create your 'target' knowledge map. Find the difference and tackle it. This means mapping out what data structures and algorithms you do know and what you ought to know and the difference is where the win is.
- Enjoy it! If you have to force yourself thru these questions, you are probably not meant to be doing them and most probably not meant to have the job that has an interview that asks these questions. And its alright.