Short answer: ABC: Always Be Coding.
1. The more you code, the better you’ll get — it’s that simple. By coding, you’re practicing. But the best practice is focused practice. Have goals in mind, explore new areas, and challenge yourself. Over time, you should develop a portfolio of both unfinished and finished projects. GitHub is a great place to put this portfolio on display, but just having an eclectic body of work is huge.
2. Re-build the wheel. You should implement the most common data structures in the language you’re trying to learn. Do not rely on common libraries. Implement the following and write tests for them: vector (dynamic array), linked list, stack, queue, circular queue, hash map, set, priority queue, binary search tree, etc. You should be able to implement them quickly as you get more comfortable with the language.
3. Solve word problems. Spend time coding solutions to different types of problems. One of the best resources is TopCoder. , then try solving problems. Pick those that test your ability to implement recursive, pattern-matching, greedy, dynamic programming, and graph problems. Just go through a bunch of .
This is probably the number one reason I was hired at Google. I spent literally two weeks obsessed with TopCoder. After that, I could code Dijkstra’s algorithm with my eyes closed and one arm tied behind my back. I could solve almost any kind of graph-problem under the sun. It was all problem-solving repetition. And as Eric Schmidt says, “Repetition doesn’t spoil the prayer.”
4. Build small products. Look at the startups around you, can you rebuild some portion of their product? Chances are you can do it in a weekend. You can build the initial essence of Google in a weekend (PageRank over a structured document corpus) if you really want.
Again, just keep coding. Keep a growing list of projects and ideas for what you can build in minutes, days and weeks.