Google Software Engineer Coding & Algorithms Interview Questions
Practice the exact questions companies are asking right now.
Parse strings and find meeting slots
Question Given a text file where each line contains raw information, extract the user identifier and the numeric quantity on that line and store the r...
Remove elements to avoid k-prefix duplicates
Question Given two lists listA and listB and an integer k, delete elements from listB so that the first k elements of the new listB share no value wit...
Find shortest path with blocked nodes
Question Given an unweighted graph, a start node, an end node, and a block_set of nodes that cannot be traversed, return the length of the shortest pa...
Match people to questions using tags and priorities
You are building a simplified “Q&A matching” feature. You have: - people: N people, where person i has a set of expertise tags P[i]. - questions: M qu...
Maximize 1D deliveries within distance and minimize total distance
You are given positions on a 1D line: - people: an array of N integers (positions of people) - shops: an array of M integers (positions of milk-tea sh...
Compute shortest delivery route with dangerous stops
Delivery Route Planning With Dangerous Stops You are given delivery stops (nodes) and a set of routes. Each route is a list of stops, and you can trav...
Recommend top-K movies from similarity graph
Movie Recommendation: Top K You are building a simple movie recommendation feature. Input - A set of movies 0..(M-1). - An undirected similarity graph...
Compute city skyline outline
You are given a list of rectangular buildings in a 2D city skyline. Each building is represented by three integers [L, R, H]: - L: the x-coordinate of...
Shuffle array using random integer API
You are given an array nums of length n representing a deck of distinct cards. You do not have access to a built-in shuffle function, but you are give...
Find maximum value in huge text file
You are given the path to a very large text file on disk. The file has the following properties: - Each line contains exactly one signed 64-bit intege...
Find longest duplicated substring
You are given a string s consisting of lowercase English letters. A substring of s is any contiguous sequence of characters, i.e., s[i..j) for 0 ≤ i <...
Find largest digit-sharing subset
You are given an array of N integers. Each integer has exactly two decimal digits (i.e., each element is between 10 and 99 inclusive). You want to cho...
Maximize coins with tokens moving by +3
You are given a 1D board represented by a string s of length n (1 <= n <= 100). Each character is one of: - '.': empty cell - 'C': a cell containing o...
Find largest group of two-digit numbers sharing digits
You are given an integer array A of length n (1 <= n <= 100). Each element is a two-digit number (e.g., from 10 to 99). Two numbers are considered con...
Solve chat, grid paths, and car rentals
You are given three independent programming tasks. For each, describe and implement an efficient algorithm, and be prepared to analyze its time and sp...
Add two big integers from digit lists
You are given two non-empty singly linked lists (or arrays) representing two non-negative integers. The digits are stored in reverse order, and each n...
Find safe travel intervals between planet influences
You are planning a space route along a one-dimensional line (the x-axis). You are given a list of planets. Each planet is represented by an integer pa...
Count same-color squares in a character grid
You are given a 2D grid (matrix) of characters. Each character represents a color: cells with the same character are considered the same color. Formal...
Find mode in a trinary search tree
You are given the root of a trinary search tree where each node has up to three children: `text class Node { int val; Node left; // all values ...
Compute minimal transfers to settle group expenses
Problem A group of friends go on a trip and share expenses. Each expense is recorded as an object: - payer (string): who paid the full amount - amount...