Google Coding & Algorithms Interview Questions
Master your tech interview with our curated database of real questions from top companies.
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...
Implement Sampling and Minimize Loss in Numerical Coding
Scenario Numerical coding challenges on sampling and loss minimization. Question a) Implement functions to sample from truncated normal distributions ...
Remove Duplicates While Preserving Order in List
Scenario A data pipeline receives an unordered list of IDs containing duplicates; downstream components require a duplicate-free list while preserving...
Normalize Columns in Binomial Matrix Efficiently
Scenario Write code that creates a 100×100 matrix of Binomial(1, 0. 5) samples and normalizes each column so it sums to 1. Question Provide an efficie...
Determine If Two Strings Are Anagrams Efficiently
Scenario Backend service needs to verify whether two user-provided strings are anagrams for text-matching features. Question Implement a Python functi...
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...
Implement percentage RMSE and bootstrap its CI
Given a CSV with columns [country, actual_revenue, predicted_revenue], define percentage RMSE as pRMSE = sqrt(mean_i((pred_i/actual_i − 1)^2)). a) Imp...
Compute precision–recall curve on imbalanced data
You receive a CSV with columns: actual_label ∈ {0,1} and predicted_prob ∈ [0,1]; the positive class rate is ≈5%. a) Which evaluation metrics would you...
Minimize L2, L1, and quantile losses
Given an array X of n real numbers, derive the value θ that minimizes the sum of squared deviations Σ(xi−θ)² (mean) and the sum of absolute deviations...
Implement longest subarray summing to k
Given an integer array nums (length ≤ 200,000; values may be negative) and integer k, return the maximum length and the [l, r] indices of a contiguous...
Simulate Coin Flips to Determine Fairness via Empirical Distribution
Scenario You must test whether a coin is fair by simulation. Question Write code that repeatedly simulates n coin flips, records the number of heads, ...
Solve meeting scheduling and robot cleaning tasks
You are given two independent coding problems. --- Problem 1: Prioritized Meeting Scheduling You are asked to schedule meetings in a single meeting ro...
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 <...
Design data structure similar to LRU cache
You are asked to design and implement a data structure that behaves similarly to an LRU (Least Recently Used) cache, but with a small variation: - The...
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...
Implement anagram check and stable deduplication
Part A — Anagram checker: Write a function is_anagram(a: str, b: str, locale: str = 'en') -> bool that returns True iff a and b are anagrams under the...