title-img


Fix Flight Itinerary - Google Top Interview Questions

You are given a list of uppercase alphabet strings itinerary and a two-dimensional list of uppercase alphabet strings edges. itinerary contains the list of airports you visited in order but the airport names may be misspelled. Each element in edges contains [source, dest] meaning there is a flight that goes from source to dest. Every airport has the same length of 3. Return the minimum number of characters you can change in itinerary such that the itinerary becomes valid. You can

View Solution →

Graph Weight Queries - Google Top Interview Questions

You are given two two-dimensional list of integers edges and queries. edges represents an undirected graph and each element is in the form [x, y, w] meaning that vertices x and y are connected with edge weight w. queries is also in the form [x, y, w] and represents the question of does there exist a path between x and y such that each edge in it have weight of at most w. Return the number of queries that are true. Constraints n ≤ 100,000 where n is the length of edges m ≤ 100,0

View Solution →

Hop Cost - Google Top Interview Questions

You are given two lists of integers nums0 and nums1 of the same length as well as integers dist and cost. You must start off at index 0 at either nums0 or nums1 and want to end up at the last index of either list. In each round, you can choose to switch to the other list for cost of cost. And then you can jump forward at most dist distance away where the cost of landing at an index is the value at that index. Return the minimum total cost possible to finish the task. Constraints

View Solution →

Job Scheduling to Maximize Profit - Google Top Interview Questions

You are given a two-dimensional list of integers intervals where each list contains three values [start, finish, profit]. Given you can only perform one task at a time, return the most amount of profit you can gain. Constraints n ≤ 10,000 where n is the length of intervals. Example 1 Input intervals = [ [1, 2, 50], [3, 5, 20], [6, 19, 100], [2, 100, 200] ] Output 250 Explanation We can take intervals [1, 2, 50] and [2, 100, 200] Exam

View Solution →

K-Distinct Sublists - Google Top Interview Questions

Given a list of integers nums and an integer k, return the number of sublists such that there's exactly k distinct numbers in the sublist. Constraints k ≤ n ≤ 100,000 where n is the length of nums Example 1 Input nums = [1, 1, 2, 3] k = 2 Output 3 Explanation We have the following sublists which have exactly 2 distinct numbers: [1, 1, 2], [1, 2], [2, 3]

View Solution →