title-img


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 →

K Lexicographically Smallest Subsequence - Google Top Interview Questions

Given a list of integers nums and an integer k, return the lexicographically smallest subsequence of length k. Constraints k ≤ n ≤ 100,000 where n is the length of nums Example 1 Input nums = [1, 2, 0, 9, 2, 3] k = 3 Output [0, 2, 3] Example 2 Input nums = [10, 1, 0] k = 2 Output [1, 0]

View Solution →