Maximize the Minimum Value After K Sublist Increments- Google Top Interview Questions
You are given a list of integers nums and integers size and k. Consider an operation where we take a contiguous sublist of length size and increment every element by one. Given that you can perform this operation k times, return the largest minimum value possible in nums. Constraints n ≤ 100,000 where n is the length of nums k < 2 ** 31 Example 1 Input nums = [1, 4, 1, 1, 6] size = 3 k = 2 Output 2 Explanation We can increment [1, 4, 1] to get [2, 5, 2,
View Solution →Maximize the Number of Equivalent Pairs After Swaps - Google Top Interview Questions
You are given a list of integers of the same length A and B. You are also given a two-dimensional list of integers C where each element is of the form [i, j] which means that you can swap A[i] and A[j] as many times as you want. Return the maximum number of pairs where A[i] = B[i] after the swapping. Constraints n ≤ 100,000 where n is the length of A and B m ≤ 100,000 where m is the length of C Example 1 Input A = [1, 2, 3, 4] B = [2, 1, 4, 3] C = [ [0, 1],
View Solution →Maximum Product Path in Matrix - Google Top Interview Questions
You are given a two-dimensional list of integers matrix. You are currently at the top left corner and want to move to the bottom right corner. In each move, you can move down or right. Return the maximum product of the cells visited by going to the bottom right cell. If the result is negative, return -1. Otherwise, mod the result by 10 ** 9 + 7. Constraints 1 ≤ n, m ≤ 20 where n and m are the number of rows and columns in matrix -2 ≤ matrix[r][c] ≤ 2 Example 1 Input
View Solution →Max Multiplied Pairings Sequel - Google Top Interview Questions
You are given two lists of integers nums and multipliers. For each i = 0 to i = multiplers.length - 1, inclusive, perform the following operation: Remove one integer e from either the beginning or the end of nums Add multipliers[i] * e to your running total Return the maximum total possible after performing the operations. Constraints 0 ≤ m ≤ n ≤ 1,000 where n is the length of nums and m is the length of multipliers Example 1 Input nums = [5, 2, -7] multipliers = [2, 4, -
View Solution →Minimum Time to Finish K Tasks - Google Top Interview Questions
You are given a two-dimensional list of integers tasks where each element has 3 integers. You are also given an integer k. Pick k rows from tasks, call it S, such that the following sum is minimized and return the sum: max(S[0][0], S[1][0], ...S[k - 1][0]) + max(S[0][1], S[1][1], ...S[k - 1][1]) + max(S[0][2], S[1][2], ...S[k - 1][2]) In other words, each of the 3 columns contribute to a cost, and is calculated by taking the max value of that column in S. The max of an empty li
View Solution →