IMG_3832

How I Improved My Coding Speed In One Week

A lot of people are asking whether coding speed matters in coding interviews. The short answer is – yes, it’s extremely important.

Over the past, Gainlo interviewers have seen so many candidates who came up with the right solution quickly but failed to complete the code in the end. This phenomenon has become more and more common and that’s why we decided to talk about it this week.

This week, Jared will share his interview preparation experience, especially on how he improved his coding speed in a week. He used to be a slow programmer but has successfully got offers from Google, Facebook, Amazon and various other companies later on. We are glad to have the chance to interview him and we’ve summarized all the tips in this post.

 

Why does coding speed matter?

Long time ago, I (Jared) had no idea at all about coding speed in programming interviews. I thought that interviewers would challenge me with a couple of questions and I provided the answer maybe with code, and then it was done. So it’s all about whether I can solve the problem or not.

I didn’t realize the importance of coding speed until I failed several coding interviews in a row with very similar reason. I found myself pretty good at coming up with solutions, however, it could take me half an hour to complete the code. I believe that there are many people with the same frustration.

Normally, candidates will be asked one to two questions per interview (~45min) and most likely coding is required. In other words, we only have less than 20min per question (removing “trash time” in the beginning and end), which is more challenging than it seems to be.

In addition, a lot of people don’t even pay attention to coding speed like I used to be. They don’t have the mindset that finishing the code in a short period of time is equally important as solving the problem itself. This is because if we don’t have enough time to code in an interview, it’s as bad as we fail to solve the problem.

 

Coding speed != typing speed

Some people think that in order to speed up coding, we need to improve typing speed or writing speed on a whiteboard. But in reality, typing speed is really not important at all.

I found a couple of reasons that I had been slow in coding:

  1. Sometimes I was not clear enough in my mind when coding. In other words, I didn’t even have a concrete solution before rushing to code.
  2. I was just slow in coding. For example, it could take me a long while to implement a recursion since I’ve got to go back and keep “refactoring” the code.
  3. I was right too fast on a whiteboard and I just wanted to be fast. The result was that my code screwed up and I didn’t know what I was writing about sometimes.

Because all of these things, I made up my mind to improve my coding speed and here are some techniques that work pretty well to me.

 

Tip #1 – Clear mind

It may sound counterintuitive, but it’s never too late to write your solution until you have a concrete idea in your mind. Sometimes I felt like I’ve spent too much time thinking and couldn’t wait to start coding my solution, which was the disaster. Probably someone can think while coding, but it never works for me.

Instead, what I found more effective is to start coding only after I’m confident enough about my approach. I would first discuss my solution with the interviewer, which could verify my idea to some extent. I might start coding later than average people, but I’m pretty sure that my solution works and I won’t waste time writing or even drawing randomly on the whiteboard.

A good way to check if your idea is concrete enough is to see if you can transform your idea into pseudo code. You don’t need to write it down, but if you find a specific part of the logic is not that clear, you’d better think more about it.

 

Tip #2 – Write down code for every question

The biggest mistake I’ve made previously was that I’d like to claim I’ve solved this problem without a single line of code. However, the truth is that having the right idea is not even close to solving a coding interview question. Only after I started coding my solutions did I realize the importance of solid code.

In the beginning, I found it hard to put my thoughts into real code, especially with a time limit. The best example is to implement binary search. Everyone is able to explain what binary search is, but only 10% of programmers can implement bug-free binary search. I’m wondering what if we put a time constraint.

So what I did later is to put SOLID code for every question I’ve prepared. If I was preparing a phone screen, I would code online. If it was an onsite interview, I would find a whiteboard. I began to notice the difference of my coding speed after practicing with ten or twenty questions.

 

Tip #3 – Optimize your code

Part of the reason we are slow in coding is that our code is crappy. More specifically, the code is either redundant or unreadable (maybe both) and it’s extremely hard to debug. A good example is to implement memcpy function and see if you end up with a duplicate piece of code.

One way for me to improve this is to optimize my code after I finish the question I prepared. It’s not about optimizing the memory and speed, it just optimizes the code itself, making it cleaner and more concise. Little by little, I can write better code in the first place and avoid a lot of common pitfalls.

 

Tip #4 – Track your time

I would never know how slow I was before I started tracking the time. Human beings are just not good at estimating time in general. Many times I thought I was fast enough, but it turned out to be much slower than I expected. I found that I just need a timer to tell me exactly how much time I’ve used.

A side effect of this is to give me some pressure. When I put a timer next to me, I would feel a little more nervous and that’s exactly what I need because I don’t want to be too nervous in a coding interview.

In addition, I can see my progress over time, which is really fulfilling.

 

Tip #5 – Language

This tip is totally optional. I find Python much simpler than Java in terms of solving coding interview questions. It has a much more concise syntax and makes it faster for me to code. But if Python is not something you are already familiar, I won’t suggest people bother to switch to it.

 

Final thought

Coding speed is easier to improve than it seems to be and I never expected that I could improve a lot within a short period of time. The number one thing is to keep practice and track your improvement. Writing code to every question you prepare can be intimidating, but just because of this, it can make you stand out from rest of the candidates.

The post is written by Gainlo - a platform that allows you to have mock interviews with employees from Google, Amazon etc..

I'd like to learn more

Share on Facebook19Tweet about this on TwitterShare on LinkedIn35Share on Reddit0

Leave a Reply

Your email address will not be published. Required fields are marked *