In our previous blog posts, we covered a lot of interview preparation tips and hacks about what you should do before and in an interview in order to better your chance of getting hired. However, there are quite a few red flags in code interview that can potentially make you fail even if you have a good performance in other areas.
Dynamic programming is a nightmare for a lot of people. Although not every technical interview will cover this topic, it’s a very important and useful concept/technique in computer science.
Again, similar to our previous blog posts, I don’t want to waste your time by writing some general and meaningless ideas that are impractical to act on. Instead, the aim of this post is to let you be very clear about the basic strategy and steps to use dynamic programming solving an interview question. And with some additional resources provided in the end, you can definitely be very familiar with this topic and hope to have dynamic programming questions in your interview.
Normally at the end of each interview, you’ll get the chance to ask questions to the interviewer. Many people don’t pay much attention to this part because they believe it won’t make any difference to the interviewer’s decision and feedback and they also have no idea about what kind of questions to ask at the end of an interview. However, it’s not always true. What I really want to suggest here is to take every opportunity you have to boost your chance.
As we are having more and more experienced interviewers in Gainlo, we realized that we can help our users in many ways besides mock interview. That’s why we started our first AMA from experienced interviewers last week, which allows anyone to ask us questions regarding code interview preparation tips and we’ll collect and organize answers from several our most experienced interviews.
How do you write perfect code in an interview?
From industry experience and Gainlo interviewers feedback, majority of candidates wrote crappy code in interviews, which could be bugs, terrible coding style, inconcise, confusing and so on. It’s also worth to note that there’s a significantly better chance for cleaner code to get hired because they tend to have less bugs, easy to understand and look much more professional.
Like other posts in this blog, we’ll give you very detailed and practical tips to improve code quality instead of telling you some very general ideas. Some tips won’t take you 30min to acquire, others may take a little longer. They are all very practical and you don’t need to have years experience or write a lot of codes.
1. Language selection
Most companies allow candidate to choose whatever languages they like and the most common ones are definitely C++ and Java. Although they shouldn’t have a big difference as both languages are so popular, we see significant advantages when using C++ compared to Java.
First of all, C++ has a much more concise syntax. Remember that normally you only have no more than 20min to solve a coding question and if removing the time you spend on thinking and discussing, you would usually have less than 10min to code your solution. With that in mind, C++ would allow you to write the exactly same solution with less code and less time. Try to compare list/vector and class definition, you will definitely get an idea how verbose Java is.
People always asked us what I should do to prepare for an interview within several weeks. This post is not teaching you any sort of shortcuts or tricks that let you get offers without efforts, instead we want to help you only focus on things that have huge impact on your preparation, thus compress your preparation time within a month. In addition we’ll recommend only one or two resources in each section since there’s no need for you to check a 300 page book or tens of websites.
Pareto principle teaches us that 80% of the effects come from 20% of the efforts, in other words majority of people’s preparation work only have trivial effects on their interview performance. The key to be efficient in preparation is not getting any super secret resources, instead is by eliminating useless effort and be more focused on those 20% work.
After interviewing a lot of Gainlo interviewers, it’s quite clear that certain preparation patterns/hacks do exist and they can definitely be compressed into weeks. In fact, many of them got their job offers only within 3 weeks preparation. Let’s see how those guys including me are using this model and how you can do the same.
Day 0: Make concrete timeline and stick to it
Given a month preparation time, it’s very important to make full use of every single day. A common pattern of failure is that people either don’t know what to do or have no time in the end. They don’t have a detailed plan and they’ve no idea of the workload for each task.
So the first thing to do before your preparation is always making a detailed plan. You should be clear about how many hours per day you’ll spend on preparation, how many stages are there, how long is each one and so on so forth. What we highly recommend is to have some fixed period of time everyday that is only used for interview preparation.
If you’ve been a software engineers for a little while, you will always heard that new grads performed much better in job interviews than experienced engineers in average. It sounds weird, right? Experienced engineers have years experiences in software industry and have interviewed and been interviewed for many times before, they should always have better performance. However it is not the case.
From anonymous statistics collected by Gainlo, for general technical interviews more than half of new grads performed better than experienced professionals and some engineers with years experience may even failed in the simplest questions.
So let’s look into this interesting issue and this post will give experienced developer tips on how to prepare for an interview.
Strengths and weakness of experienced engineers
To better understand why new grads performed well, it’s important to be more aware of experienced engineers’ strengths and weakness.
Working experiences is no doubt the #1 advantage of experienced engineers. from our mock interviewers’ feedbacks, engineers with more than a year working experiences usually have better understanding of the whole industry and also know more techniques like AWS, NoSQL etc.. In addition, they tend to have better communication skills and describe their ideas much more concise and clear.
A lot of people asked us what would be an ideal interview process and what do interviewers expect from a candidate. The answer may vary case by case since different company has different preferences, but I’d like to cover some general rules that can make your interview process more predictable and clear.
What is an ideal process?
Unless you are those super talented candidates who can solve a coding question within 5min perfectly, the interviewer will always expect you to have a short discussion about the problem. You may clarify some conditions, or you may talk about your hunch. After 5-10min in general, you are expected to come up with a solution no matter how terrible it is. The solution can be very slow or consume lots of memory, but it’s ok as long as it works.
Then based on the solution, the interview expects you to further optimize it. You may discuss a lot with the interviewer and he can give you hints and evaluate your reaction based on the hint. In general, you should try to optimize the solution step by step and be very clear about it’s time/space complexity.
Finally, you will write solid code for your solution. The interview may ask you to go thru the code with some test inputs to prove it actually works.
1. Many candidates didn’t talk about the simplest solution first because they thought it’s not optimal. However I always encourage people to do that as it shows you can solve the problem at least with some approaches. And in the worst case that you are suck there, the interviewer can give you hints based on your solution or he can at least provide some feedback.
Over the past, we received a lot of emails asking us questions regarding software engineer interview preparation and tons of questions have been asked over and over again. So we decided to make our first blog post as an aggregator of all those common questions/pitfalls that our users have.
1. Which data structures I should focus on when I don’t have enough time?
I’d suggest people always focus on those very basic data structures for interview. Data structures like tree, linked list, queue, stack are the most popular topics in programming interview and you will definitely get in trouble if you are caught unfamiliar with any of them. Graph is also important, but just not as popular as the others (this is purely based on experience).
So do spend enough time and be clear and familiar with these fundamental stuffs, and then try to practice with real interview questions about these data structures.