Saturday, April 13, 2024

How To Get Good At Coding Interviews

Don't Miss

Best Resources For Coding Interviews

How I Got Good at Coding Interviews

The selection of good resources is very important for success in your coding interviews. If you chose the wrong resource then more than money, you will lose the valuable time you need for preparation, hence spending some time researching for a good resource.

If you need recommendations, the following are some of my the tried and tested resources to learn Data Structure and Algorithms in-depth for coding interviews:

And, if you prefer books, there is no better than the Cracking The Coding Interview, by Gayle Laakmann McDowellwhich presents 189+ Programming questions and solutions. A good book to prepare for programming job interviews in a short time. Btw, I will also earn some money if you buy any of these resources mentioned here.

Introduce A Data Structure Or Abstract Data Type

This is where a study of data structures really helps. If you can identify the bottleneck, you can start to try to throw data structures at the problem to see if there are any performance or spatial gains.

Going back to the Zeros to the End problem we did earlier, our bottleneck is likely the step of putting elements at different indexes. In that case, we may realize that using a counter variable is beneficial.

Note that the data structure doesn’t need to be fancy. In our case, we’re literally introducing a single int variable– but sometimes that’s all you need.

What should the counter be counting? Well, once we’ve split the array up into non-zeros and zeros , we only really care about where the non-zeros end.

Because we don’t need to worry about what is in the array after non-zero elements, we can simply keep a separate pointer to track the index of the final array. It will let us know where to start the zeros.

We could then write the follow pseudocode to utilize this strategy:

insert_position = 0for i in nums  if i is not 0    increase insert_position    keep it in insert_position  fill the rest in with 0

Despite having two loops, the time complexity simplifies to O. However, the space complexity is constant since we’re using the same array, so we have an improvement!

Use Pseudocode To Clarify Your Thoughts

Unless an algorithm is extremely simple, you’ll want to write pseudocode first.

This is especially true for brute-force solutions. The interviewer may be okay with just the pseudocode for the first pass, and could ask you to spend the remaining time solving and coding an optimized solution.

Additionally, thinking in pseudocode is much easier to modify should you find a deleterious error. Here’s what it might first look like:

temp = zero_count = 0iterate through array:  if nonzero, push to new temp  if zero, increment countfor zero_count times:  push to tempreturn temp

It’s a good sign you’re on the right track if the interviewer modifies the problem to make it a bit more complicated. They might do this by adding a constraint , or by making the input significantly larger. In my experience, most interviewers will plan to do one easy problem and one harder problem.

Interviewer: Great, now can you do this without instantiating a new array?

Don’t lose your cool at this point, and also don’t get too excited about passing the first part. It’s time to tie our brute force solution to a technique to improve it. We will now cover a number of ways to do so.

Don’t Miss: System Design Interview Preparation

Now Youre Ready For The Coding Interview

These are some of the most common questions outside of data structure and algorithms that help you to do really well in your interview.

I have also shared a lot of these questions on my blog, so if you are really interested, you can always go there and search for them.

These common coding, data structure, and algorithm questions are the ones you need to know to successfully interview any company, big or small, for any level of programming job.

If you are looking for a programming or software development job in 2019, you can start your preparation with this list of coding questions and if you are ready for an Interview then you can also take TripleBytes quiz and go directly to the final round of interviews with top tech companies like Coursera, Adobe, Dropbox, Grammarly, and many more.

Develop A Strong Foundation

Google Coding Interview With A Facebook Software Engineer

I have talked about this issue before, but one of the most important keys to success in coding interviews is having a strong foundation of Computer Science fundamentals.

Over time, Ive developed many different techniques to help my students improve their problem solving in their interviews, like the FAST Method. However, none of these techniques are valuable if you dont have strong fundamentals under your belt.

For example, the FAST Method is designed to help students with dynamic programming. The first step of the FAST Method is to find an initial brute force recursive solution. This is something that you need to be able to do on your own for the FAST Method to be of any use to you. Even if you understand the methodology, it wont help you if you dont know how to get that initial solution.

If you have strong fundamentals, then recursion is something that shouldnt be difficult for you. It is a topic that comes up frequently enough that you should be able to whip it out whenever you want.

Such is the case with all other fundamental data structures and algorithms. If you dont know how to implement a linked list, then it doesnt matter how many tricks you learn for solving linked list problems.

Recommended Reading: Top 10 Behavioral Questions

A Note About Video Resources

Some videos are available only by enrolling in a Coursera or EdX class. These are called MOOCs.Sometimes the classes are not in session so you have to wait a couple of months, so you have no access.

It would be great to replace the online course resources with free and always-available public sources,such as YouTube videos , so that you people can study these anytime,not just when a specific online course is in session.

Coding Interviews Are Becoming Harder

As time passes, more experienced and well-practiced candidates keep the bar high for performance expectations in a coding interview. Couple that the general outlook for programming jobs you are in a very competitive market.

Don’t Miss: Interview Attire Womens

Dont Know Why Youre Failing Coding Interviews Its Likely This

Picture this: You just had your first coding interview and you are confident you will pass to the next stage. You discussed different approaches, you found the optimal solution, you implemented it and described the Big O time complexity. And the verdict comes: You wont pass to the next stage! It happened to me before

Mirror The Work To Be Done

Best FREE Way to get Good at Coding Interviews in 2022

Stay away from algorithmic quizzes and brain teasers. As intriguing as they can be, relying solely on them can show you how good the candidate is at technical interviews. Youre essentially assessing whether they have the iterative algorithmic problem-solving attitude developers teach themselves in order to ace interview coding challenges. There are sites teaching people to get these interview skills and developers have no choice but to comply if they want to work at certain companies. As an employer, you have an important decision to make here. You can either follow this trend or screen technical skills with objective and fair coding challenges for jobs.

Don’t Miss: Women’s Outfit For Job Interview

Weeks 9 & 10 System Design Interviews

System design interviews are now an integral part of the software engineering interview process particularly if you are applying for a senior role. These interviews have a significant impact on your hiring level.

Learn distributed systems concepts like Cap Theorem, Consistency, Partitioning, Load-Balancing etc.

Look at the course Grokking the System Design Interview for more design interview practice.

As part of your System Design Interviews, you are asked to design a web-scale service. Interviewers are interested in evaluating your ability to describe the different parts of a scale-able service, such as:

  • How are web-servers load-balanced?
  • How are large files stored?
  • How is the network set up for redundancy and maximum throughput?

Youll want to practice questions like:

  • Design Instagram

Check out my article the Top 10 System Design Interview Questions for Software Engineers for more example questions, tips, and resources for the System Design Interview.

How To Use It

Everything below is an outline, and you should tackle the items in order from top to bottom.

I’m using GitHub’s special markdown flavor, including tasks lists to track progress.

Create a new branch so you can check items like this, just put an x in the brackets:

Fork a branch and follow the commands below

Fork the GitHub repo by clicking on the Fork button.

Clone to your local repo:

git add .git commit -m "Marked x"git rebase jwasham/maingit push --set-upstream origin progressgit push --force

Recommended Reading: Interview With Cfo

How Long Should I Prepare For A Coding Interview

Coding interview preparation time largely depends on the interviewee’s level of experience. If you’re an entry-level programmer, it’s a good idea to spend at least twelve weeks preparing. If you have more experience, 4-8 weeks is suggested for interview prep.

Study the company’s programming language and tools of choice. Practice a couple of coding challenges each day â don’t let your practice be a cram session right before your coding interview. Finally, as you practice, make sure to time yourself to see how you are progressing.

There Is No Perfect Solution

Reacting to My Google Coding Interview

The guideline given to the interviewers doesnt include any solution. There is no predefined or preferred solution that can be used to compare with the solution written by the candidate.

Interviewers dont necessarily remember every single line of a solution. We know the one or two approaches, but its totally up to the candidates to drive their own solution.

Sometimes we dont like seeing candidates quickly derive a solution as if they have seen the question beforehand. Its more surprising to see organic solutions driven by the thought process of the candidate on the spot. Although its lengthy and overcomplicated, wed like to see how the candidates come up with that solution.

Don’t Miss: Preparing For System Design Interview

What To Do If You Blank Out Completely

With almost any technical challenge, if you have the right approach, you can figure out a way to solve a problem. But what if you genuinely have no idea where to start?

So let’s address something quickly– if you really have no clue, here’s what to do.

Let’s say you’re a frontend engineer with a few years of Javascript Single Page App development under your belt. You’re asked the following technical question in an interview.

When would you apply asynchronous communication between two backend systems?

You freeze, and suddenly your chest tightens. You’ve never worked on any backend systems, and you’ve forgotten what asynchronous means. For a few seconds, you stare at the interviewer, and your mind has nowhere to go.

Here’s two potential ways to address this:

  • Link it to something you’ve done
  • Emphasize how excited you are to learn and work on such things
  • The first response works because it still allows you to demonstrate your experience:

    I haven’t directly worked on backend systems, but can you remind me what asynchronous means again? Ah, a form of a programming that allows work to be done separately from the primary application thread? I’ve done something similar with React– sometimes inserting data into the database via a REST endpoint takes some time, but we want to give immediate feedback to the user that it’s being persisted. So **my educated guess* is that it would be when you want to have a process do something while waiting for something else to complete.*

    Internalize Key Tech Interview Question Patterns

    Many coding interview solutions actually involve a similar set of key patterns – and learning them will help you solve any long tail problem that is outside the set of commonly asked coding interview questions.


    Out of the resources on the internet – AlgoMonster is an excellent platform created by Google engineers. It uses a data-driven approach to condense software engineering coding interview questions into a set of key patterns, and summarized them into a structured, easy to digest course. Imagine LeetCode, but with only the key patterns you need to know.

    Best of all, AlgoMonster is not subscription-based – pay a one-time fee and get lifetime access. Join today for a 70% discount

    Grokking the Coding Interview: Patterns for Coding Questions

    This course on Educative expands upon the questions on the recommended practice questions but approaches the practicing from a questions pattern perspective, which is an approach I also agree with for learning and have personally used to get better at coding interviews. The course allows you to practice selected questions in Java, Python, C++, JavaScript and also provides sample solutions in those languages.

    Learn and understand patterns, not memorize answers! Join today for a 10% discount

    And that is all from me – for more detail on each step of the software engineer coding interview preparation process, do dive into each topic within my handbook through the sidebar or by navigating to the next page!

    Recommended Reading: Best System Design Interview Prep

    Best Tips To Crack Coding Interviews In 2022

    Here are a few of my practical tips to crack your next coding interview. These are hard-earned and I learned from my own mistakes and experience.

  • There is no better way to do well in Coding interviews than practicing as many coding problems as possible. This will not only train your mind to recognize algorithmic patterns in problems but also give you the much-needed confidence to solve problems you have never seen before.
  • My second tips are to learn about as many data structure and algorithms as possible. This is an extension of the previous tip but it also involves reading and not just practicing. For example, If you know about the hash table you can also many array and counter-based problems easily. The same is true for trees and graphs.
  • Choosing the right data structure is a very important part of software development and coding interview and unless and until you know them, you wont be able to choose.
  • Time yourself candidates who solve interview problems within the time limit and quickly are more likely to do well in the interview so you should also time yourself.
  • Think of edge cases and run your code through them. Some good edge cases might be the empty input, some weird input, or some really large input to test the boundary conditions and limits.
  • We Want Candidates To Be Successful

    Coding Interviews Be Like

    Recruiting is an expensive process. Believe it or not, we want you to get the job more than you want it for yourself. A lot of hours are invested in hiring one candidate. If a candidate doesnt get the offer, we have to do the same work all over again to fill in that missing role.

    Although interviewers look fierce and almighty, we are not there to sabotage the candidates. We represent the face of the company. We want the candidates to have one of the best experiences in their interviews. We want to promote the benefits of working in the company to you as much as possible because we know youre not going for only one interview.

    Don’t Miss: Interview Questions For A Cfo

    Week 11 Os And Concurrency Concepts:

    Today, even budget laptops and mobile phone have multiple cores. Understanding concepts like Threads, Locks, Synchronization, etc. are beneficial whether you are building a mobile app or a web-scale service.

    Just like System Design interview questions Multi-Threading and Concurrency Interview questions are useful in gauging your level. A junior engineer will struggle with these questions . A relatively senior engineer is supposed to do better in such questions as they would be responsible for writing a lot of code that takes advantage of multiple cores/threads.

    C.H. Afzals Multithreading and Concurrency for Senior Engineering Interviews series is an important one to check out, and available in multiple programming languages.

    Lack Of Practice Is Obvious

    Some questions are hard especially when youre applying for a big tech company, but for most tech companies, questions are pretty basic. The coding interview is not about testing what solution you can come up with. Its about testing how you come up with your solution.

    Its easy to tell whether candidates are struggling with the difficulty of the question or battling with the syntax. If you have your dominant programming language, use that one for the interview. There is no need to try the language that is more favorable in the job description.

    Most of the candidates are struggling with the basic syntax. Im not talking about Graph or Tree. Im talking about the traditional For loop. For example, there are many things that could go wrong:

    for   i++) 
    • You might forget to add spaces. Yes, formatting does matter. It shows whether you care about the readability of the code.
    • You might mix up .length, input.length , and input.size.
    • You might write i < = input.length, and youll run into index out of bounce exception.

    Recommended Reading: Mailscoop Io

    Learn All Essential Data Structure And Algorithms

    My third tips are to learn about as many data structure and algorithms as possible. This is an extension of the previous tip but it also involves reading and not just practicing.

    You should know about all essential data structures like an array, linked list, string, hash table, and binary tree, etc. For example, If you know about the hash table you can also many array and counter-based problems easily. The same is true for trees and graphs.

    Choosing the right data structure is a very important part of software development and coding interview and unless and until you know them, you wont be able to choose.

    If you need resources, I have shared some useful books and free online courses to learn Data Structure algorithms, you can check them out at your convenience.

    More articles

    Popular Articles