title-img


Every Sublist Min Sum- Google Top Interview Questions

You are given a list of integers nums. Return the sum of min(x) for every sublist x in nums. Mod the result by 10 ** 9 + 7. Constraints n ≤ 100,000 where n is the length of nums Example 1 Input nums = [1, 2, 4, 3] Output 20 Explanation We have the following sublists and their mins: min([1]) = 1 min([1, 2]) = 1 min([1, 2, 4]) = 1 min([1, 2, 4, 3]) = 1 min([2]) = 2 min([2, 4]) = 2 min([2, 4, 3]) = 2 min([4]) = 4 min([4, 3]) = 3 min([3]

View Solution →

Fruit Basket Packing - Google Top Interview Questions

You are given a two-dimensional list of integers fruits. Each fruits[i] contains [cost, size, total], meaning that fruit i costs cost each, each one has size of size, and there are total of total of them. You're also given k number of fruit baskets of capacity capacity. You want to fill the fruit baskets with the following constraints in this order: Each basket can only contain fruits of the same kind Each basket should be as full as possible Each basket should be as cheap as pos

View Solution →

First to Count to Target- Google Top Interview Questions

You are playing a game against a friend where in each round you pick a number from 1 to k to add to a shared running total that initially starts from 0. The first person to reach or exceed the running total to target wins. Given that you go first, return whether you can force a win if everyone plays optimally. Constraints k ≤ 30 target ≤ 1,000 Example 1 Input k = 5 target = 9 Output True Explanation If we pick 3 first, then whether your friend picks 1, 2, ..

View Solution →

Gene Mutation Groups - Google Top Interview Questions

You are given a list of unique strings genes where each element has the same length and contains characters "A", "C", "G" and/or "T". If strings a and b are the same string except for one character, then a and b are in the same mutation group. If strings a and b are in a group and b and c are in a group, then a and c are in the same group. Return the total number of mutation groups. Constraints n ≤ 10,000 k ≤ 20 where k is the length of a string in genes Example 1 Input

View Solution →

Grid Coloring - Google Top Interview Questions

You are given a two-dimensional list of integers matrix. Each element matrix[r][c] represents a oolor 0 or 1. In one operation you can set the color of matrix[0][0] and all the connected (vertically and horizontally) cells that are of the same color as index (0, 0). Return the minimum number of operations required to change all cells in the matrix to the same color. Constraints 0 ≤ n, m ≤ 250 where n and m are the number of rows and columns in matrix matrix[r][c] = 0 or matrix[r][

View Solution →