Google software engineer interviews cover algorithms, data structures, system design, and coding problems drawn from real interview rounds.
Question Design a data structure to maintain a dynamic set of points on a 2D coordinate plane. Support operations to insert points, remove points,...
Input: ListStreamBuffer class that buffers a stream of integer latency samples in FIFO order and supports O(1) access to both the minimum and maximum...Input: Integer(s)+ and -, and parentheses ( and ), simplify...Input: Stringid, project, start, end, slots, and savings. Times are integer minutes relative to a common epoch; execution occupies [start, end).BASE_MIN_SAVINGS rejects savings below 5.00; SLOT_CAP rejects requests above 100 slots. Report every violated rule.plan_queries(jobs: list[dict[str, str]]) -> candidate_defined_typeExample 1:{
"jobs": [
{"id":"a","project":"analytics","start":"0","end":"30","slots":"80","savings":"8.00"},
{"id":"b","project":"analytics","start":"20","end":"50","slots":"100","savings":"12.00"},
{"id":"c","project":"reporting","start":"30","end":"60","slots":"60","savings":"9.00"},
{"id":"d","project":"reporting","start":"60","end":"70","slots":"20","savings":"4.00"},
{"id":"e","project":"analytics","start":"60","end":"80","slots":"120","savings":"15.00"}
]
}{
"selected_ids": ["a", "c"],
"total_savings": "17.00",
"rejected": [
{"id":"d","rules":["BASE_MIN_SAVINGS"]},
{"id":"e","rules":["SLOT_CAP"]}
]
}a and c touch without overlapping and save 8.00 + 9.00 = 17.00, exceeding b alone at 12.00. Query d fails the 5.00 savings floor; e exceeds the 100-slot cap.Part 2 — Project policies and a launch budgetproject, min_savings, max_duration, and cooldown. The planner also receives an integer max_jobs, limiting the number of selected queries.PROJECT_MIN_SAVINGS rejects savings below min_savings, and PROJECT_MAX_DURATION rejects execution duration end - start above max_duration.end + cooldown, even if the next query belongs to another project. Its effective occupied interval is [start, end + cooldown). The duration rule still measures only end - start.max_jobs queries. A limit of zero is valid and produces an empty schedule, but eligibility checks must still run.reservations, in execution order, containing each selected query's id and string-valued available_at, equal to end + cooldown.plan_with_policies(jobs: list[dict[str, str]], policies: list[dict[str, str]], max_jobs: int) -> candidate_defined_typeExample 2:{
"jobs": [
{"id":"a","project":"alpha","start":"0","end":"20","slots":"80","savings":"8.00"},
{"id":"b","project":"beta","start":"20","end":"40","slots":"90","savings":"11.00"},
{"id":"c","project":"alpha","start":"30","end":"50","slots":"70","savings":"10.00"},
{"id":"d","project":"beta","start":"50","end":"70","slots":"100","savings":"13.00"},
{"id":"e","project":"beta","start":"70","end":"90","slots":"60","savings":"9.00"}
],
"policies": [
{"project":"alpha","min_savings":"10.00","max_duration":"30","cooldown":"10"},
{"project":"beta","min_savings":"5.00","max_duration":"25","cooldown":"0"}
],
"max_jobs": 2
}{
"selected_ids": ["b", "d"],
"total_savings": "24.00",
"rejected": [
{"id":"a","rules":["PROJECT_MIN_SAVINGS"]}
],
"reservations": [
{"id":"b","available_at":"40"},
{"id":"d","available_at":"70"}
]
}a passes the base floor but fails alpha's 10.00 floor. All execution durations are 20, within the respective limits. Query c would occupy [30, 60), conflicting with both b and d. The cap prevents selecting b, d, and e together, which would save 33.00. The best allowed pair is b + d = 11.00 + 13.00 = 24.00, versus d + e = 22.00, b + e = 20.00, and c + e = 19.00.Example 3:{
"jobs": [
{"id":"u","project":"alpha","start":"0","end":"20","slots":"101","savings":"4.00"},
{"id":"v","project":"alpha","start":"0","end":"10","slots":"100","savings":"10.00"},
{"id":"w","project":"beta","start":"10","end":"20","slots":"100","savings":"10.00"},
{"id":"x","project":"beta","start":"15","end":"25","slots":"100","savings":"10.00"},
{"id":"y","project":"beta","start":"25","end":"35","slots":"100","savings":"10.00"}
],
"policies": [
{"project":"alpha","min_savings":"10.00","max_duration":"15","cooldown":"5"}
],
"max_jobs": 2
}{
"selected_ids": ["v", "x"],
"total_savings": "20.00",
"rejected": [
{"id":"u","rules":["BASE_MIN_SAVINGS","PROJECT_MAX_DURATION","PROJECT_MIN_SAVINGS","SLOT_CAP"]}
],
"reservations": [
{"id":"v","available_at":"15"},
{"id":"x","available_at":"25"}
]
}u violates four rules: 4.00 < 5.00, duration 20 > 15, 4.00 < 10.00, and 101 > 100 slots. Query v releases the reservation at 10 + 5 = 15, so it conflicts with w but can precede x. Several two-query schedules save 10.00 + 10.00 = 20.00; ["v", "x"] is lexicographically smallest. The launch cap prevents the otherwise compatible three-query schedule ["v", "x", "y"].Notes:2,000 jobs, IDs are unique nonempty ASCII strings of length at most 64, and each project has at most one policy; in Part 2, 0 <= max_jobs <= 30.0 <= start < end <= 10^9, slots are positive integers, savings are nonnegative decimal strings with exactly two fractional digits, and monetary values fit in signed 64-bit cents when summed. Policies have min_savings >= 5.00, positive max_duration, and nonnegative cooldown, each time quantity at most 10^9.(origin, destination, departure, arrival), where airport names are strings and times are integer minutes measured from a common epoch. Each flight can be used only at its listed departure time.A traveler is at airport source at time ready_time and wants to reach target as early as possible. The following rules apply:source at a time in the inclusive interval [ready_time, ready_time + max_layover]. The minimum connection time does not apply before the first flight.t, the next flight must depart from that airport in the inclusive interval [t + min_connection, t + max_layover].target among all valid itineraries, or -1 if none exists. If source == target, return ready_time without taking a flight.A single earliest-arrival label per airport is not necessarily sufficient: arriving too early can make a later departure violate the maximum layover.Function signatureearliest_arrival(flights: list[tuple[str, str, int, int]], source: str, target: str, ready_time: int, min_connection: int, max_layover: int) -> int{
"flights": [["S", "A", 0, 2], ["S", "A", 1, 6], ["A", "T", 8, 10]],
"source": "S",
"target": "T",
"ready_time": 0,
"min_connection": 1,
"max_layover": 3
}10
S are initially available because their departures lie in [0, 3]. Arriving at A at time 2 permits departures only in [3, 5], so that arrival cannot connect. Arriving at time 6 permits departures in [7, 9], allowing the flight departing at 8 and arriving at T at 10.Example 2:{
"flights": [["S", "A", 0, 2], ["A", "T", 6, 8]],
"source": "S",
"target": "T",
"ready_time": 0,
"min_connection": 1,
"max_layover": 3
}-1
A at time 2, but the permitted connection window is [3, 5]. The departure at 6 is too late.Constraints:0 <= len(flights) <= 200000.200000 distinct airports occur across the flights, source, and target.0 <= departure < arrival <= 10^12.0 <= ready_time <= 10^12.0 <= min_connection <= max_layover <= 10^12.2 * 10^12.O(m log(m + 1)) time and O(m + 1) auxiliary space, where m is the number of flights; do not explicitly construct all possible flight-to-flight connections.1s in a binary matrix.m x n binary matrix filled with 0s and 1s, your task is to return the area of the largest rectangle containing only 1s. You must implement maximalRectangle(matrix: List[List[int]]) -> int.Example 1:1s in the matrix.Constraints:m == matrix.lengthn == matrix[i].lengthO(m*n) time.AutocompleteSystem that supports the following operations:input(char c: char) -> List[str]: Accepts a character and returns a list of the top 3 suggested terms that start with the current input string based on weighted frequency.addSentence(sentence: str, times: int) -> None: Adds a new sentence with its corresponding frequency.1000.100 characters.get(key: int) -> int: Returns the value of the key if the key exists, otherwise return -1.put(key: int, value: int) -> None: Update the value of the key if the key exists. Otherwise, add the key-value pair to the cache. If the number of keys exceeds the capacity from this operation, the least recently used key should be removed.10^4.Sign up for free to access walkthroughs, AI-generated questions, and more.
Get Started Free