Leave your Email to get the latest Google interview questions weekly. No spam we promise.
Google Online Assessment 2019
Fill 2D Array
Given a n*n 2D array. Fill the integer from 1 to n*n to this 2D array that makes the sum of each row, each column and the two diagonal equal.
Given an int n, return all possible representations of n in Fibonacci base.
A pizza shop offers n pizzas along with m toppings. A customer plans to spend around x coins. The customer should order exactly one pizza, and may order zero, one or two toppings. Each topping may be ordered only once.
Given the lists of prices of available pizzas and toppings, what is the price closest to x of possible orders? Here, a price said closer to x when the difference from x is the smaller. Note the customer is allowed to make an order that costs more than x.
Given a String, find the minimum number of deletions required to convert it into a palindrome.
Given an integer n, return the representations in Fibonacci base for the integer from 1 to n.
Given a binary grid where 0 represents water and 1 represents land. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. Delete all islands except their borders. A border is land adjacent to water. You may assume all four edges of the grid are surrounded by water
Normal palindrome is defined as a string that reads the same backwards as forwards, for example "abccba".
Given an input string representing one word, write a method that returns the start and end indices of all extensions in the word.
Given an integer N which represents number of edges, where bases are always 2.Find how many trapezoid you can create with the integer N?
Given an array return an integer indicating the minimum number of swap operations required to sort the array into ascending order.
Given a run-length encoded string s and a width of a board. Assume that the board is filled from left to right such that each line has exactly width chars. Return the run-length encoded string that represents the board rows from right to left without constructing the board.
Given 2 run-length encoded strings s and t. Determine if they represent the same string.
There are n students [0, ..., n-1] participate in a marathon. You are given an int array standings where standings[i] = j means that student j finished just before student i. Return the students in the order in which they finished the marathon.
Given an encoded string str, return true if and only if this string contains the specified secret word.
Given 2 strings pin and guess. Write a function to provide a hint that indicates how digits in guess match the pin.
Given two strings s and t, determine if you can convert s into t.
In a 2d array of integer, 2 denotes wall, 1 denotes zombie and 0 denotes human.
Google Interview Questions 2019
Find and Remove Redundant Edge in Binary Tree,
Assign Bicycles to the Closest Rider,
Google Robot in Maze Problem
1.1 Count Number of Ways in Matrix
1.2 Count Number of Ways with Obstacles in Matrix
1.3 Count Number of Ways Detour for North
Build Google Calculator For all Search Inputs
Count of Smaller Numbers
Two people in a game, player scores by claiming nodes in binary tree, tree node class as shown above.
The player who eventually owns more nodes wins the game.
Player A and B each claims a node at first.
After the first round, a player will only be able to claim a node adjacent to any node owned by himself.
A tree node is adjacent to its parent, left right and right child.
A node owned cannot be re-claimed.
End game when all nodes are owned.
If player A gets the first claim at node N, find whether it is possible for player B to win.
If yes, find out which node player B should claim at his first move.
Given the left view and front view of the skyline of a block as two arrays, find the maximum total height of buildings in the block.
Build a text editor class with the following functions,
insertCharacter(char) //insert the char right before cursor
backspace() //delete the char right before cursor
Google On-site 2018 Winter
There are orbs on an NxM board ('O' denotes orb. 'X' denotes empty slot).
Whenever two orbs are in the same column or the same row, you get to erase one of them.
Try to erase as many orbs as possible.
Find the minimum number of orbs remained on board eventually.
Given a tree with n nodes. Each node has k coins, where 0 <= k <= n . There are total n coins on the tree. The goal is to move the coins such that each node has exactly one coin. What's the minimum moves required?Each move can only move one coin to an adjacent node.
Given the length and width of a matrix, get the number of paths from bottom-left to bottom right.
Give an array A of n integers where 1 <= a[i] <= K. Find out the length of the shortest sequence that can be constructed out of numbers 1, 2, .. k that is NOT a subsequence of A.
Given two two integer arrays, find the longest common subsequence.
eg: a =[1 5 2 6 3 7], b = [5 6 7 1 2 3]. return [1 2 3] or [5 6 7]
Implement an iterator to flatten a 2d vector.
Letter Combinations of a Phone Number
Find Peak Element
Fraction to Recurring Decimal
Binary Search Tree Iterator
Number of Islands
Implement Trie (Prefix Tree)
Kth Smallest Element in a BST
Power of Two
Search a 2D Matrix II
Strobogrammatic Number II
Group Shifted Strings
Flatten 2D Vector
Meeting Rooms II
Binary Tree Paths
Graph Valid Tree
Closest Binary Search Tree Value
Encode and Decode Strings
Walls and Gates
Unique Word Abbreviation
Game of Life
Flip Game II
Binary Tree Longest Consecutive Sequence
Best Time to Buy and Sell Stock with Cooldown
Minimum Height Trees
Super Ugly Number
Binary Tree Vertical Order Traversal
Maximum Product of Word Lengths
Number of Connected Components in an Undirected Graph
Wiggle Sort II
Power of Three
Verify Preorder Serialization of a Binary Tree
Flatten Nested List Iterator
Reverse Vowels of a String
Moving Average from Data Stream
Android Unlock Patterns
Design Snake Game
Count Numbers with Unique Digits
Logger Rate Limiter
Sort Transformed Array
Design Hit Counter
Max Sum of Rectangle No Larger Than K
Largest Divisible Subset
Plus One Linked List
Find K Pairs with Smallest Sums
Guess Number Higher or Lower
Guess Number Higher or Lower II
Combination Sum IV
Kth Smallest Element in a Sorted Matrix
Design Phone Directory
Insert Delete GetRandom O(1)
Linked List Random Node
Longest Absolute File Path
Find the Difference
Remove K Digits
Queue Reconstruction by Height
Valid Word Abbreviation
Pacific Atlantic Water Flow
Sentence Screen Fitting
Maximum XOR of Two Numbers in an Array
Valid Word Square
Number of Boomerangs
Find All Numbers Disappeared in an Array
Sort Characters By Frequency
Repeated Substring Pattern
Encode String with Shortest Length
Ones and Zeroes
License Key Formatting
Max Consecutive Ones
Predict the Winner
Max Consecutive Ones II
Find Mode in Binary Search Tree
Next Greater Element II
The Maze II
Longest Uncommon Subsequence I
Longest Uncommon Subsequence II
Longest Word in Dictionary through Deleting
Lonely Pixel I
Lonely Pixel II
Encode and Decode TinyURL
Reverse String II
Diameter of Binary Tree
Output Contest Matches
Boundary of Binary Tree
Binary Tree Longest Consecutive Sequence II
Student Attendance Record I
Longest Line of Consecutive One in Matrix
Delete Operation for Two Strings
Add Bold Tag in String
Maximum Average Subarray I
Find Duplicate Subtrees
Find K Closest Elements
Split Array into Consecutive Subsequences
Beautiful Arrangement II
Repeated String Match
My Calendar II
Sentence Similarity II
First Unique Character in a String
Shortest Completing Word
Largest Number At Least Twice of Others
Bold Words in String
Find Anagram Mappings
Escape The Ghosts
Domino and Tromino Tiling
Number of Matching Subsequences
Find Eventual Safe States
Largest Triangle Area
Largest Sum of Averages
Positions of Large Groups
Flipping an Image
Find And Replace in String
New 21 Game
Magic Squares In Grid
Keys and Rooms
Backspace String Compare
Maximize Distance to Closest Person
Peak Index in a Mountain Array
Median of Two Sorted Arrays
Regular Expression Matching
Merge k Sorted Lists
Trapping Rain Water
Longest Consecutive Sequence
Longest Substring with At Most Two Distinct Characters
Word Break II
Word Search II
The Skyline Problem
Sliding Window Maximum
Closest Binary Search Tree Value II
Expression Add Operators
Find Median from Data Stream
Serialize and Deserialize Binary Tree
Smallest Rectangle Enclosing Black Pixels
Number of Islands II
Range Sum Query 2D - Mutable
Count of Smaller Numbers After Self
Number of Atoms
My Calendar III
Cracking the Safe
Couples Holding Hands
Max Chunks To Make Sorted II
Minimize Max Distance to Gas Station
Swim in Rising Water
Transform to Chessboard
Bricks Falling When Hit
Sum of Distances in Tree
Similar String Groups
Guess the Word
Shortest Path Visiting All Nodes
Minimum Window Subsequence
Remove Duplicate Letters
Shortest Distance from All Buildings
Create Maximum Number
Count of Range Sum
Longest Increasing Path in a Matrix
Longest Substring with At Most K Distinct Characters
Russian Doll Envelopes
Rearrange String k Distance Apart
Trapping Rain Water II
Minimum Unique Word Abbreviation
Optimal Account Balancing
Sliding Window Median
Smallest Good Base
Student Attendance Record II
Maximum Vacation Days
Median Employee Salary
Erect the Fence
Maximum Average Subarray II
Kth Smallest Number in Multiplication Table
K Empty Slots
Redundant Connection II
Maximum Sum of 3 Non-Overlapping Subarrays