Google Interview Questions: 75 You Can Expect In Your Interview

January 18, 2021

Google is one of the most sought-after companies as far as jobs are concerned, especially on the software engineering side. In this post, we’ll mention 75 of the most common questions in Google interviews and how you can use Tech Interview Pro, a proven program offering hundreds of coding walk-throughs that also prepares you for the soft side of the interview, to breeze through them.

Let’s face it: Google is perhaps the biggest of the FAANG companies and everyone out there wants to work in it.

It’s for that same reason that actually getting a job at Google is no walk in the park.

After all, you can’t expect to become an SWE at Google without going through your share of technical and behavioral questions: and most of Google’s questions, in particular, are pretty hard.

Thanks to the wonders of the Internet, though, you actually have a chance of preparing for them. Here’s a list of the top 75 questions you can expect to be asked by Google during your technical interviews.

#1 Google Technical Questions

  1. Given an array of strings, find out in how many cases is any of the anagrams of the string at location i, a substring of the string at location i+1.
  2. Given two DOM trees, check if they have the same text.
  3. Given a target sum, populate all subsets, whose sum is equal to the target sum, from an int array.
  4. Given a list of rectangles, pick a random point within one of the rectangles where the likelihood of a point is based on the area of the rectangle.
  5. Write a function to generate a random number without using any library functions.
  6. Generate a random binary tree with equal probability.
  7. Given a dictionary, output the longest string.
  8. Find the “local minimum” in a binary tree.
  9. Given an array of sorted integers, find the closest value to the given number. (The array may contain duplicate values and negative numbers)
  10. Given an extremely large file that contains parentheses, write a function that determines if the parentheses are balanced.
  11. Given two strings (a and b), write a function that prints out the minimum number of flips of the characters in such a way that a is an anagram of b.
  12. Given a string, write a function that outputs the largest alphabetical order of all consecutive substrings. (For example, string “ab”, substring “a”, “ab”, “b”, output “b”)
  13. Given the width, height, start and endpoints, and a list of random points of a grid, write a function that goes through these points and determines how many paths are there from the start point to the endpoint. (You can only move from “i, j” down and right)
  14. Given a pair of strings, write a function that determines whether they can become the same after a single swap of two characters in one string.
  15. Given a string, finds all duplicate substrings of length k.
  16. Write a function that finds the last index of the last duplicate number in a sorted array.
  17. Given a dictionary, generate the shortest string that is both a palindrome and a pangram.
  18. Given a binary matrix, write a function that counts the number of squares that can be formed by values of 0.
  19. Given a list of N threads, detect a deadlock in the system.
  20. Write a function that checks if there are two subarrays that are identical in an array.
  21. Write a function that converts a sorted linked list into a complete BST.
  22. Given a random list of appointments, write a function that finds every colliding appointment.
  23. Given a chessboard, write a function that checks if a group of white pieces is surrounded by black pieces.
  24. Write a function that takes two numbers (no matter how big) as strings and returns the result as a single string.
  25. Given an array of integers, write a function that finds out how many unique BSTs can be generated from the array.
  26. Given an array of integers, find out how many combinations in the array satisfy the equation x+y+z = w
  27. Write a function that finds the top 10 most frequent words in the past hour, day, and month on Twitter.
  28. Write a function that reverses a linked list.
  29. Given a word of length n, and n six-sided dice with a character on each side, write a function that finds out if this word is constructible by the set of given dice.
  30. Given a dictionary of words & miss-spelled inputs, write a function that will find 3 words from the dictionary which are closest to the given input.
  31. Write a function that finds the shortest cycle in a graph with a given node.
  32. Given a start node and an end node in a graph, write a function that reports if they are “necessarily connected” (i.e: all paths from the start node lead to the end node)
  33. What is the difference between move and forward in C++?
  34. Given two strings of equal length (a and b), find whether it is possible to cut both strings at a common point such that the first part of A and the second part of B form a palindrome.
  35. Given various subsequences of an array, write a function that prints the full array.
  36. Given two extremely similar strings, write a function that finds an extra character in any of the two.
  37. Given two integer arrays, write a function that finds the longest common subsequence.
  38. Given a set of points, find the smallest rectangle by its area.
  39. Given a text file, remove all duplicate lines.
  40. Explain a linear piecewise function.
  41. Write a function that finds if two persons are blood-related in a family tree.
  42. Given a binary tree, write a function that returns the longest path.
  43. Write a function that generates a random 4-digit even number.
  44. Given an array of integers, write a function that prints all values that are greater than every number on its left and smaller than every number on its right.
  45. Given a sorted array, write a function that finds every number that occurs more than n/4 times.
  46. Write a function that checks if two given binary trees are mathematically equivalent.
  47. Given a list of words with both lower and upper cases, write a function that finds all words that have the same unique character set.
  48. Write a function that finds the leaf node value from a sequence in a BST without rebuilding it.
  49. Given the map of a village represented as a 2D grid containing houses, bushes, and open-spaces, write a function that finds a point for conducting a meeting in the map.
  50. Write a function that finds the largest and smallest number in a list.

Coding Answer Examples

All examples written in C++.

Coding Example #1: Write a function that reverses a linked list

// Iterative C++ program to reverse
 a linked list
#include <iostream>
using namespace std;
/* Link list node */
struct Node {
    int data;
    struct Node* next;
    Node(int data)
        this->data = data;
        next = NULL;
struct LinkedList {
    Node* head;
    LinkedList() { head = NULL; }
    /* Function to reverse the linked list */
    void reverse()
        // Initialize current, previous and
        // next pointers
        Node* current = head;
        Node *prev = NULL, *next = NULL;
        while (current != NULL) {
            // Store next
            next = current->next;
            // Reverse current node's pointer
            current->next = prev;
            // Move pointers one position ahead.
            prev = current;
            current = next;
        head = prev;
    /* Function to print linked list */
    void print()
        struct Node* temp = head;
        while (temp != NULL) {
            cout << temp->data << " ";
            temp = temp->next;
    void push(int data)
        Node* temp = new Node(data);
        temp->next = head;
        head = temp;
/* Driver code*/
int main()
    /* Start with the empty list */
    LinkedList ll;
    cout << "Given linked list\n";
    cout << "\nReversed Linked list \n";
    return 0;

Coding Example #2: Given a set of points, find the smallest rectangle by its area

// C++ implementation of a program that finds the smallest rectangle by its area
#include <bits/stdc++.h> 
using namespace std; 
// function to find minimum area of Rectangle 
int minAreaRect(vector<vector<int>> A){ 
    // creating empty columns 
    map<int,vector<int>> columns; 
    // fill columns with coordinates 
    for(auto i:A) 
    map<pair<int,int>,int > lastx; 
    int ans = INT_MAX; 
    for (auto x:columns) 
        vector<int> column = x.second; 
        sort(column.begin(), column.end()); 
        for (int j = 0; j < column.size(); j++) 
            for (int i = 0; i < j; i++) 
                int y1 = column[i]; 
                // check if rectangle can be formed 
                if (lastx.find({y1, column[j]}) != lastx.end()) 
                    ans = min(ans, (x.first - lastx[{y1, column[j]}]) * 
                            (column[j] - column[i])); 
                lastx[{y1, column[j]}] = x.first; 
    if (ans < INT_MAX) 
        return ans; 
        return 0; 
// Driver code 
int main() 
    vector<vector<int>> A = {{1, 1}, {1, 3}, {3, 1}, {3, 3}, {2, 2}}; 
    cout << (minAreaRect(A)); 
    return 0; 

Coding Example #3: Given a binary tree, write a function that returns the longest path

// C++ program to print the longest leaf to leaf
// path
#include <bits/stdc++.h>
using namespace std;
// Tree node structure used in the program
struct Node {
    int data;
    Node *left, *right;
struct Node* newNode(int data)
    struct Node* node = new Node;
    node->data = data;
    node->left = node->right = NULL;
    return (node);
// Function to find height of a tree
int height(Node* root, int& ans, Node*(&k), int& lh, int& rh, 
                                                     int& f)
    if (root == NULL)
        return 0;
    int left_height = height(root->left, ans, k, lh, rh, f);
    int right_height = height(root->right, ans, k, lh, rh, f);
    // update the answer, because diameter of a
    // tree is nothing but maximum value of
    // (left_height + right_height + 1) for each node
    if (ans < 1 + left_height + right_height) {
        ans = 1 + left_height + right_height;
        // save the root, this will help us finding the
        //  left and the right part of the diameter
        k = root;
        // save the height of left & right subtree as well.
        lh = left_height;
        rh = right_height;
    return 1 + max(left_height, right_height);
// prints the root to leaf path
void printArray(int ints[], int len, int f)
    int i;
    // print left part of the path in reverse order
    if (f == 0) {
        for (i = len - 1; i >= 0; i--) {
            printf("%d ", ints[i]);
    // print right part of the path
    else if (f == 1) {
        for (i = 0; i < len; i++) {
            printf("%d ", ints[i]);
// this function finds out all the root to leaf paths
void printPathsRecur(Node* node, int path[], int pathLen, 
                                         int max, int& f)
    if (node == NULL)
    // append this node to the path array
    path[pathLen] = node->data;
    // If it's a leaf, so print the path that led to here
    if (node->left == NULL && node->right == NULL) {
        // print only one path which is equal to the 
        // height of the tree.
        if (pathLen == max && (f == 0 || f == 1)) {
            printArray(path, pathLen, f);
            f = 2;
    else {
        // otherwise try both subtrees
        printPathsRecur(node->left, path, pathLen, max, f);
        printPathsRecur(node->right, path, pathLen, max, f);
// Computes the diameter of a binary tree with given root.
void diameter(Node* root)
    if (root == NULL)
    // lh will store height of left subtree
    // rh will store height of right subtree
    int ans = INT_MIN, lh = 0, rh = 0;
    // f is a flag whose value helps in printing
    // left & right part of the diameter only once
    int f = 0;
    Node* k;
    int height_of_tree = height(root, ans, k, lh, rh, f);
    int lPath[100], pathlen = 0;
    // print the left part of the diameter
    printPathsRecur(k->left, lPath, pathlen, lh, f);
    printf("%d ", k->data);
    int rPath[100];
    f = 1;
    // print the right part of the diameter
    printPathsRecur(k->right, rPath, pathlen, rh, f);
// Driver code
int main()
    // Enter the binary tree ...
    //           1
    //         /   \     
    //        2     3
    //      /   \   
    //     4     5
    //      \   / \ 
    //       8 6   7
    //      /
    //     9
    struct Node* root = newNode(1);
    root->left = newNode(2);
    root->right = newNode(3);
    root->left->left = newNode(4);
    root->left->right = newNode(5);
    root->left->right->left = newNode(6);
    root->left->right->right = newNode(7);
    root->left->left->right = newNode(8);
    root->left->left->right->left = newNode(9);
    return 0;

Coding Example #4: Write a function that finds the top 10 most frequent words in the past hour, day, and month on Twitter

#include <vector>
#include <unordered_map>
#include <queue>
#include <string>
#include <iostream>

using namespace std;

class WordFrequency {
        WordFrequency(int period) : period_(period)
            head_ = 0;
            tail_ = 0;

        void AddWord(uint32_t time, const string &word)
            uint64_t &word_id = word_to_word_id_[word];
            if (word_id == 0) {
                word_id = words_.size();
            ++slots_[time % period_][word_id];
            head_ = time;

        vector<string> GetTopWords(uint32_t time, int n)
            vector<string> out;
            if (time < head_)
                return out;
            for (auto it = period_words_.begin(); it != period_words_.end(); ++it)
                uint64_t word_id = it->first;
                uint64_t count = it->second;
                if (pq.size() < n)
                    pq.push(PQElement(word_id, count));
                else if ( < count)
                    pq.push(PQElement(word_id, count));
            while (!pq.empty())
            reverse(out.begin(), out.end());
            return out;

        class PQElement {
                PQElement(uint64_t word_id, uint64_t count) : word_id_(word_id), count_(count)
                bool operator<(const PQElement &other) const
                    if (count_ == other.count_) {
                        return word_id_ > other.word_id_;
                    return count_ > other.count_;
                uint64_t word_id_;
                uint64_t count_;

        void TrimTail(uint32_t time)
            int new_tail = time - (period_ - 1);
            if (new_tail > tail_)
                int tail_augment = new_tail - tail_;
                if (tail_augment > period_)
                    tail_augment = period_;
                for (int i = 0; i < tail_augment; ++i)

        void DecrementWordCounts(uint32_t slot_idx)
            unordered_map<uint64_t, uint64_t> &slot_words = slots_[slot_idx %= period_];
            for (auto it = slot_words.begin(); it != slot_words.end(); ++it)
                uint64_t word_id = it->first;
                uint64_t count = it->second;
                period_words_[word_id] -= count;
                if (period_words_[word_id] == 0)

        int period_;
        unordered_map<string, uint64_t> word_to_word_id_;
        vector<string> words_;
        vector<unordered_map<uint64_t, uint64_t>> slots_;
        unordered_map<uint64_t, uint64_t> period_words_;
        uint64_t max_word_id_;
        uint32_t head_;
        int tail_;
        priority_queue<PQElement> pq;

void Print(const vector<string> &words)
    for (auto w : words)
        cout << w << "\n";
    cout << "---\n";

int main()
    WordFrequency wf(60);

    wf.AddWord(1, "cat");
    wf.AddWord(1, "cat");
    wf.AddWord(10, "rat");
    wf.AddWord(15, "cat");
    wf.AddWord(15, "bat");
    wf.AddWord(20, "rat");
    wf.AddWord(21, "dog");
    wf.AddWord(21, "dog");

    Print(wf.GetTopWords(21, 3));

    wf.AddWord(21, "dog");
    wf.AddWord(41, "rat");
    wf.AddWord(41, "rat");

    Print(wf.GetTopWords(41, 3));

    wf.AddWord(55, "dot");
    wf.AddWord(61, "net");
    wf.AddWord(100, "let");

    Print(wf.GetTopWords(100, 3));

    return 0;

Coding Example #5: Write a function to generate a random number without using any library functions

#include <stdlib.h>
#include <time.h>
#include <stdio.h>

int main(void)
    unsigned long j;
    srand( (unsigned)time(NULL) );

    for( j = 0; j < 100500; ++j )
        int n;
        while( ( n = rand() ) > RAND_MAX - (RAND_MAX-5)%6 )
        { /* bad value retrieved so get next one */ }

        printf( "%d,\t%d\n", n, n % 6 + 1 );

    return 0;#include <iostream>
#include <chrono>
#include <random>

int main()
    std::random_device rd;
    // seed value is designed specifically to make initialization
    // parameters of std::mt19937 (instance of std::mersenne_twister_engine<>)
    // different across executions of application
    std::mt19937::result_type seed = rd() ^ (
                ).count() +
                ).count() );

    std::mt19937 gen(seed);

    for( unsigned long j = 0; j < 100500; ++j )
    /* ^^^Yes. Generating single pseudo-random number makes no sense
       even if you use std::mersenne_twister_engine instead of rand()
       and even when your seed quality is much better than time(NULL) */    
        std::mt19937::result_type n;
        // reject readings that would make n%6 non-uniformly distributed
        while( ( n = gen() ) > std::mt19937::max() -
                                    ( std::mt19937::max() - 5 )%6 )
        { /* bad value retrieved so get next one */ }

        std::cout << n << '\t' << n % 6 + 1 << '\n';

    return 0;
}#include <stdlib.h>
#include <time.h>
#include <stdio.h>

int main(void)
    unsigned long j;
    srand( (unsigned)time(NULL) );

    for( j = 0; j < 100500; ++j )
        int n;
        while( ( n = rand() ) > RAND_MAX - (RAND_MAX-5)%6 )
        { /* bad value retrieved so get next one */ }

        printf( "%d,\t%d\n", n, n % 6 + 1 );

    return 0;

Travel With Peace Of Mind

Staying safe and healthy while you travel has never been more important than it is today. Join the world’s most user-friendly insurance company, SafetyWing, for less than $1.50/day. Cancel penalty-free any time.

#2 Google Behavioral Questions

  1. How did you find this role?
  2. What do you know about this company?
  3. What are you looking for in your next role?
  4. Tell me about a time when you solved a conflict at work.
  5. Which of the company values/principles is your greatest strength?
  6. How do you move forward with stakeholders who want to go in one direction but you don’t think that’s the right way to do it?
  7. Describe a time you took on a project risk and failed.
  8. Tell us about a time you executed a new task or project.
  9. What are three things you consider important to maintain work-life balance?
  10. Tell us about an accomplishment you’re particularly proud of and why.
  11. How are you going to impact the team after you join?
  12. Why Google?
  13. Have you ever faced a conflict while working as a team? If so,  how did you deal with it?
  14. Tell us about your favorite Google product. What do you think about its future?
  15. Why do you want to leave your current organization?
  16. Who do you believe are Google’s main competitors? How does Google stand apart?
  17. How do you make sure that your colleagues remain accountable?
  18. Do you think that using legal names when setting up a Gmail account should be mandatory?
  19. How do you think digital marketing will change in the next five years?
  20. Do you think Google should be charging for its productivity apps? Why or why not?
  21. How would you describe Adwords to someone completely unfamiliar with the product and online advertising?
  22. If you were tasked with increasing Gmail’s userbase, what steps would you take to make that happen?
  23. Pick an app on your phone’s home screen. What do you like and dislike about it?
  24. Why do you think that the Google search page is so mainly blank?
  25. What is the biggest threat Google faces today?

Behavioral Answer Examples

Behavioral Example #1: Why Google?

This is a common question that recruiters at Google ask, and its purpose is to find out what excites you about working with Google, naturally.

To answer this question, make sure you don’t make the answer about yourself (mentioning the salary in any way, shape, or form, for example). Instead, you can talk about your favorite Google products and what you like best about Google’s work culture.

Behavioral Example #2: Have you ever faced a conflict while working as a team? If so,  how did you deal with it?

Conflicts at workplaces aren’t uncommon, and they can happen every now and then, especially when working as a team. To answer this question, talk about how you were able to resolve a past conflict with a fellow colleague, and how you arrived at a consensus for the greater good of the project.

Behavioral Example #3: How are you going to impact the team after you join?

To answer this question, talk about fun and interesting activities that you’d like to be part of or initiate. Recruiters are always on the lookout for dynamic individuals who can bring energy and motivation to the team. 

Behavioral Example #4: What are three things you consider important to maintain work-life balance?

To answer this question, think about 3 productive activities that motivate you every day, and why you’d like to do them despite having a busy work schedule. Talk about what you expect from Google to keep yourself energized and motivated when you come in the next day.

Behavioral Example #5: Describe a time you took on a project risk and failed

To answer this question, simply don’t hesisate to reveal past failures: what matters to Google recruiters is to know whether you learned from your failure or not. 

After all, they want to know if you were humble enough to accept and learn from those mistakes in the first place.

Why use Tech Interview Pro?

Some of the questions in the lists above can be pretty easy, and I get that.

However, you can’t depend on luck to get through your interviews. You’re more likely to get questions rated Medium and Hard than you are to get questions rated Easy, and that goes for both the technical and the behavioral side.

And if you want to make sure you have the best possible chance of getting through them, you’re going to need some pretty heavy studying.

If that’s the case, then, what’s the optimal way to get that studying going?

I recommend you use Tech Interview Pro, an interview prep program designed by a former Google and Facebook software engineer who has compressed the knowledge he gathered from conducting over 100 interviews during his time into a single course.

And here are a few reasons why I recommend it.

#1 A Comprehensive Approach

Tech Interview Pro takes a thorough approach to its teaching, taking both the technical and behavioral aspects into consideration in its 20+ hours of video lessons.

Here’s TIP’s course outline:

  1. Understanding The Interview Process
  2. Four Axes of the Interview
    1. Coding
    2. Data Structures & Algorithms
    3. Systems Design
    4. Communication
  3. Interviewing Masterclass
  4. Data Structures & Algorithms
  5. 100+ Coding Sessions
  6. The Mock Interview
  7. Systems Design
  8. Transitioning Careers
  9. Negotiating & Accepting Your Offer

As you can see, TIP has a balance of both the technical and the behavioral, which is definitely more coverage than most of the tech interview prep courses out there.

#2 Private Facebook Group

Another neat feature that Tech Interview Pro grants its students is access to a private Facebook group with 1,500+ former students of the course.

Here are some of their success stories:

Tech Interview Pro Review - Success Stories
Tech Interview Pro Review - Success Stories
Tech Interview Pro Review - Success Stories

When you consider how many TIP students have landed jobs at FAANG companies thanks to the course, as well as how active and supportive the Facebook group is day to day, it’s really an invaluable resource to have.

#3 Created By An Industry Insider

Tech Interview Pro is run by an industry veteran who has reverse-engineered the hiring process to give you the best chance of success.

TechLead (Patrick Shyu) has grown his own websites to millions of users, spent his recent years working at Facebook and Google, and has conducted over 100 technical interviews for Google.

So if there’s anyone who can teach you how to ace your technical interviews, it’s this guy.

#4 Bi-Weekly Q&A Sessions

Every two weeks, TIP students can engage in Q&A sessions with the course’s founder, TechLead.

Tech Interview Pro Review

This is a huge advantage: after all, nothing’s stopping you from asking any of the questions featured on the list above, whether it’s a technical question or a behavioral one, and you can expect a thorough answer in return.

Another thing to keep in mind is that every Q&A session is recorded and ready to be accessed at any time, so there’s nothing stopping you from checking previous Q&A sessions too.

#5 Resume Reviews

Your resume will be the first thing a recruiter will see coming from your end, and making it look pretty won’t be enough: you need to make sure it knocks them out when they see it so that you can have a headstart into the interviewing process.

Considering this, TechLead will also personally review your resume and help you tailor it for the position and the company you seek to apply for.

#6 Lifetime Access

Lastly, TIP grants lifetime access to the entire course and private Facebook group, which means that you’ll be able to see new video lessons as they’re added, grow alongside the Facebook group, watch all of future Q&A sessions, and everything else.

TIP’s got your back, whether you want to land a job now or in the future.

In Summary

Getting into Google as a software engineer is no walk in the park, and both their technical and behavioral questions have a certain uniqueness to them that only makes them harder to tackle.

However, as long as you adequately prepare for these questions in advance, you should have a pretty good chance of leaving the interviewing room unscathed. To give yourself the best possible chance of success, we recommend you prepare with a more comprehensive, battle-tested solution like Tech Interview Pro.

Want to earn $50 in the next 6 minutes?

Bitbuy is a highly-rated, fully regulated Canadian crypto platform that’s giving new users $50 for depositing $250 or more. Trade with low fees and withdraw your money at any time.

Click below to claim your $50 bonus today. Offer ends August 17, 2022.
Offer ends August 17, 2022.