title-img


Largest Elements in Their Row and Column - Google Top Interview Questions

You are given a two-dimensional list of integers matrix containing 1s and 0s. Return the number of elements in matrix such that: matrix[r][c] = 1 matrix[r][j] = 0 for every j ≠ c and matrix[i][c] = 0 for every i ≠ r Constraints 0 ≤ n, m ≤ 250 where n and m are the number of rows and columns in matrix Example 1 Input matrix = [ [0, 0, 1], [1, 0, 0], [0, 1, 0] ] Output 3 Explanation We have matrix[0][2], matrix[1][0] and matrix[2][1] meet the criteria.

View Solution →

Largest Pair of Points - Google Top Interview Questions

You are given a strictly increasing list of integers nums and a list of integers values, both of the same length. Find a pair i ≤ j that maximizes values[i] + values[j] + nums[j] - nums[i] and return the value. Constraints 2 ≤ n ≤ 100,000 where n is the length of nums and values Example 1 Input nums = [0, 1, 6] values = [-5, 5, 4] Output 14 Explanation Here we can pick i = 1 and j = 2 to get 5 + 4 + 6 - 1 Example 2 Input nums = [0, 3, 6] values = [-5,

View Solution →

Maximize Binary String Score - Google Top Interview Questions

You are given a binary string s containing "1"s and "0"s. Consider splitting the string into two non-empty substrings such that a + b = s. The score of this split is defined to be the sum of the number of "0"s in a plus the number of "1"s in b. Return the maximum score possible. Constraints 2 ≤ n ≤ 100,000 where n is the length of s Example 1 Input s = "001001110111" Output 10 Explanation We can split the string into "00100" + "1110111". Then, the score is 4 + 6 =

View Solution →

Maximize Social Distancing - Google Top Interview Questions

You are given a list of integers seats containing 1s and 0s. Each element seats[i] represents a seat and is either occupied if seats[i] = 1 or empty if seats[i] = 0. Given that there’s at least one empty seat and at least one occupied seat, return the maximum distance from an empty seat to the closest occupied seat. Constraints n ≤ 100,000 where n is the length of seats Example 1 Input seats = [1, 0, 1, 0, 0, 0, 1] Output 2 Explanation We can sit at seats[4]. E

View Solution →

Max Multiplied Pairings - Google Top Interview Questions

You are given two lists of integers nums and multipliers. Consider an operation where we remove any number in nums and remove any number in multipliers then multiply them together. Given that you must repeat this operation until one of the lists is empty, return the maximum sum of the multiplied numbers. Note that the integers may be negative, zero, and/or positive. Constraints 0 ≤ n ≤ 100,000 where n is the length of nums 0 ≤ m ≤ 100,000 where m is the length of multipliers

View Solution →