Google Coding Interview Questions
Google is a behemoth in the technology world, significantly impacting the everyday lives of over 3 billion internet users across the globe. It also regularly makes the list of “most valuable brands in the world” and “the best companies to work for,” mainly due to its excellent work culture and environment. Every software engineer who wishes to scale the heights of their career dreams of landing a job at Google.
However, getting into Google isn't easy. Known to hire only the world's top talent, Google accepts less than 1% of applicants for software engineering positions. Getting hired by Google takes a great deal of effort, typically involving several hours of practice and preparation, powered by the right strategy.
This article will cover:
- The Google interview process
- What is expected of candidates during a coding interview at Google?
- Topics to prepare for Google coding interview
- Common Google coding interview questions
- How to prepare for Google coding interviews
- Tips for practicing coding challenges
- Tips for acing coding questions during the interview
- FAQs on Google coding interviews
- How can Interview Kickstart help you land a job at Google?
The Google Interview Process
Google’s interview process comprises three main rounds of interviews:
- The Technical Phone Screen Interview: This is essentially a screening round to filter candidates based on their proficiency in a programming language, and their ability to solve simple coding problems by employing programming fundamentals.
- The On-site Interview (comprising 3-5 rounds of coding and other technical skill assessments): In its on-site technical rounds, Google tests extensively for problem-solving skills. Questions center around your proficiency in core technical areas such as data structures, coding, algorithms and systems design. Typically, for Google coding round questions, you’ll need to answer these questions by coding on a real-time, collaborative editor or writing code on a whiteboard, depending on whether it's on-site or online.
- The Behavioral Interview: Behavioral questions are an extremely important component of Google interviews. Candidates are often put through many rounds of behavioral interviews. This is to help recruiters understand the attributes you will display in workplace-related situations. While every candidate mandatorily goes through a behavioral interview round, these interviews are considered more important while recruiting for upper-management positions, e.g., for the role of Engineering Manager or higher.
It may be wise to remember that no tech giant has the exact same interview process. So, you should make sure to reach out to your interviewer beforehand to understand Google's coding interview structure better.
You’re given an offer based on your performance as assessed in each individual round of the interview process.
Learn about the Google interview process in detail here.
What Is Expected of Candidates During a Coding Interview at Google?
Following is a list of things Google expects from you throughout the coding interview process. You’ll notice that these factors are very basic and human, yet manage to set a high standard:
- That you understand the problem without a lot of back and forth. Not necessarily at first shot, but quickly enough, and preferably by asking the right questions.
- That you articulate a solution, even brute force, with examples, quickly enough. Again, not necessarily at first shot, but quickly enough, to reinforce your claim that you have really understood the problem.
- That you improve your solution beyond brute force, to be optimal for practical applications. Again, not at first shot, but with proper thought articulation, enough logical leaps and taking the interviewer along with you in your thought process.
- That you write code idiomatically in a programming language you claim to know well. Not pseudocode, not hand-wavy code, but idiomatic code. Not at first shot, but quickly enough.
- That you clearly know what you know and what you don’t. If you don’t know the syntax of a function for example, then you point that out to the interviewer, make reasonable assumptions, and move on. Interviewers understand that in the real world, there is going to be an IDE.
- That you find and correct your own mistakes. Again, not at first shot, but without the interviewer needing to prod you often to go back and correct it.
Remember: You’re not expected to write perfect code on your first attempt. Even your interviewer is unlikely to have written perfect code at first shot in every interview.
Topics to Prepare for Google Coding Interviews
To ace Google’s coding interview rounds, your knowledge of algorithms and data structures needs to be above par. Pace your prep judiciously, giving yourself enough time to solve as many problems as possible around core DS and algorithms. Here’s what you should essentially be covering over the course of your prep:
- Arrays, strings, and linked lists
- Sorting algorithms — quicksort, merge sort, heap sort, etc.
- Hash tables and queues
- Trees and graphs
- Graph algorithms including greedy algorithms
- Dynamic programming
Common Google Coding Interview Questions
As an aspiring Googler, here are some common Google coding interview questions you can expect:
- For a given unsorted array “X,”consisting of non-negative integers, write a code to find the contiguous subarray that adds to the sum “S” of non-negative integers in the array.
- For a given array “X,” consisting of non-negative integer characters, write a code to find the contiguous subarray with the maximum sum.
- For a given array “X” of size N-1 consisting of numbers from 1 to N with one number missing, write a code to find the missing number in the array.
- For a given set of 2 sorted arrays “X” and “Y” with respective sizes “n” and ‘m’, write a code to merge the two sorted arrays such that their characters appear in decreasing order.
- For a given set of 2 arrays “X” and “Y” consisting of positive integers, write a code to find the total no. of pairs to satisfy the condition x^y>y^x, where “x” is an element of array “X” and “y” is an element of array “Y.”
- For a given array “K,” where all the elements in the array are distinct, write a function to find the Kth smallest element where “K” is a number and is smaller than the array’s size.
- You’re given an array “X” of size “N,” containing sets of 0s, 1s and 2s. Write a program to sort the array elements in ascending order.
- For a given array “X” of N positive integers, write a function to return the value “True” if a particular triplet (a,b,c) accurately satisfies the condition: a^2+b^2=c^2 (this is commonly called the Pythagorean Triplet problem).
- If you’re given an array “X” comprising “n” positive integers, write a function to compute the inversion count of the array.
- You’re given two Linked Lists, “A” and “B,” that are sorted. Write a code to merge the two Linked Lists.
- Explain Longest Common Sequence and Longest Increasing Subsequence in dynamic programming.
- For a given Singly Linked List “K,” write a code to select a particular “random” node from the list.
- Explain the process to implement BFS and DFS in a given graph.
- Explain how to implement the functions “strstr” and “Atoi” by citing examples.
- Write a code to find the middle element in a given Linked List “K.”
- Write a program function to implement Loop Detection and Loop Removal in a given Linked List “K.”
- For a given string “K,” write a function to eliminate duplicates from the string.
- Write a program to find out if two given strings “A” and “B” of set sizes are anagrams of each other.
- For a given binary tree “BT”, convert it into a Doubly Linked List (DLL), using the left and right pointers in the nodes as the previous and subsequent pointers in the DLL.
- For a given Binary Search Tree with unique values and two node values, write a code to find the Lowest Common Ancestor of the two given nodes in the Binary Search Tree.
- For a given Binary Tree, write a function to print the bottom view of the tree from left to right.
- For a given Binary Tree (BT), write a code to print the vertical traversal from the leftmost to right most levels.
- Explain a few Greedy Algorithms and their applications.
- Write a code to find the longest path in a given matrix m*n, where all the values in the matrix are unique. The path should be such that the cells should appear in ascending order.
- For a given string “S,” write a function to compute the length of the longest substring that has only distinct characters.
How to Prepare for Google Coding Interviews
You know the expectations, the topics to prepare, and a bunch of coding question examples. But how exactly should you prepare for and nail the Google coding interview?
Practice Is the Only Way You'll Get Better
You have to create and stick to your practice schedule. Diligently. It's surprisingly difficult to stick to simple habits, but that's often the difference between success and failure. For example., 2-4 hours a day to solve one or two problems is a great habit — necessary and often sufficient. But it's imperative that you actually do so several days a week for a number of weeks, rain or shine, in order to get cumulative benefits.
Just skimming problems and loading the solutions in your head is unlikely to be enough. Writing code is important in order to make the solutions real. When you write code, you will also discover and learn a lot of nuances of the programming language you're using, which will come handy in actual interviews and elsewhere.
Repeat the Problems
Repetition deepens your understanding of problems and their solutions. Often, patterns emerge only after repeating a number of problems. Obviously, repetition also improves recall and gives confidence.
Recall Is Critical — Leverage Mock Interviews
Interviews are not standardized tests. You can't prepare for them in a vacuum for several months and then suddenly hope to get better at the end of it all. After every few problems/days of practice, you have to do mock interviews.
Mock interviews are best done with engineers at top companies, but they can also be done with your friends and fellow seekers. Mocks will help your recall circuitry, and give you feedback about where you stand. That will in turn, either increase your confidence, or let you tweak your practice early, if required.
Follow the Thumb Rule
The thumb rule is to reach about 150 medium to challenging problems as your first milestone. By that time, assuming you've written code for those many problems and repeated them, you should feel pretty confident. But overall, let mock interviews guide your prep.
Tips for Practicing Coding Challenges
Participating in Google’s coding challenges helps you get noticed by recruiters. It isn’t that Google is going to hire you if you end up among the finalists or the top 3% in the competition. You could, however, land a coding interview with Google for a developer/engineer position.Even if you don’t have any projects listed in your CV, no open-source contributions, and average grades in college, getting to the final round in Code Jam or Hash Code can get you an interview call.
Here are some tips that will help you prepare for Google’s coding challenges:
- Familiarize yourself with concepts around algorithms and data structures. Adequate knowledge in database management, API, and distributed systems is an added advantage.
- Practice coding problems everyday for at least a month leading up to the challenge. Practicing numerous problems helps build your problem-solving skills and become a better engineer, helping you crack tough coding interviews.
- Get acclimated to the platforms used for these challenges. You can get more info in the FAQ section for each challenge.
- Pick an object-oriented programming language. You must be able to code algorithms in Python, C++, or Java.
- Coding challenges are time-bound. So make sure you practice problems within the limits of time.
- Practice problems from previous years’ challenges to get an idea of what sort of questions to expect.
- Use platforms like LeetCode, TopCoder, and CodeChef to expose yourself to a wide range of programming problems.
- Work on improving your testing and debugging skills.
- Make sure your code is easy to understand. The idea of coding challenges is to find the most optimal solution to a problem, not the lengthiest one.
Tips for Acing Coding Questions During the Interview
To help you understand what exactly goes down during a coding interview, we’ve broken it down into different phases. Read on to know what you should do during each of these phases:
The introduction phase of the interview lasts three to five minutes. In this phase, the interviewers want to know more about you, your experience, background, projects you have worked on, etc. We recommend presenting yourself in the best possible light and leave a lasting impression on the interviewer.
However, do not forget to be true to yourself. Talk about your projects, interests, and how you were able to accomplish something significant.
To ace a coding question, you must understand the problem. The problem statement presented by the interviewer will be concise. It won't have many details about the corner cases, constraints, and more. If there are ambiguities, you must build clarity so that you can effectively solve a given problem.
For example, you may ask questions such as:
- How big is the size of the input?
- How extensive is the range of values?
- Are there any duplicates within the input?
- Can you state some extreme cases of the input?
Determine an optimal solution after understanding the problem. This is where all your hardwork and weeks of practicing coding questions will come in handy. Think of which data structure or algorithm can you apply to develop the best solution.
The key is to be comfortable with the language you’re coding in. Sometimes, interviewers at Google will ask you to write your solution on a whiteboard. This means memorizing the syntax of the language you’re using.
Make sure that your code is concise and clean, making it easy for the interviewer to review. You’ll likely be asked to explain your solution to the interviewer or fix a bug.
After finishing the problem, it’s your turn to ask the interviewer if you have any questions. This is an excellent opportunity for you to learn more about the company and the job itself. Here are some questions that you can ask:
- What do you like most about your job?
- How do you find the culture of the company?
- Do you get to choose which projects to work on?
FAQs on Google Coding Interviews
- Question 1: Can I switch programming languages during the Google coding interview?
Yes. However, you need to articulate why you are switching the language. Say, for example, you cannot solve a problem in C++ and choose to use Java instead. Explain why the first choice was not effective and why you thought Java was a better solution.
- Question 2: What should I do after the Google coding interview?
It is recommended to send a follow-up email thanking the interviewers for their time (generally to be sent within 48 hours of the interview).
- Question 3: What resources will help me prepare for Google coding interviews?
Cracking the Google coding interview is not easy. The best way to practice is from others and be actively engaged in the explanations to answers. Read articles and forums about coding interviews. Also, we recommend learning from technical experts that are known to help candidates ace technical interviews at FAANG.
How Can Interview Kickstart Help You Land a Job at Google?
Preparing for Google coding interviews is a coordinated and calibrated process. You can’t expect to crack these interviews by just being smart. You’ll have to be prepared for the grind and trust the process without getting too caught up or absorbed in the outcome. Putting in the hard work is important. But what’s equally important is executing the right strategy.
The Interview Kickstart method is a proven way of helping engineers get really intimate with the basic core fundamentals of their profession — the same core fundamentals that are used to evaluate their technical chops in tough interviews.
We are the only platform with a breadth of instructors from FAANG companies who can guide you on what it takes to make the “cut.” We pioneered the concept of a structured interview prep program and are the most experienced platform.
We have already worked with over 5200 candidates, the bulk of whom are experienced working engineers. During that period we have generated over 4000 offers. The total quantum of the offers we have generated is in the hundreds of millions of dollars.
Want to know more? Sign up for our FREE webinar today. Your dream company is just one step away!