Maximal Expression - Google Top Interview Questions
Given a list of integers nums, return the maximal value that can be made by adding any binary operators +, -, and * between the numbers in nums as well as insert any valid brackets. Constraints 1 ≤ n ≤ 200 where n is the length of nums Example 1 Input nums = [-5, -3, -8] Output 64 Explanation We can make the following expression: (-5 + -3) * -8
View Solution →Maximal Points From Deleting Two Character Substrings- Google Top Interview Questions
You are given a string s containing "1"s and "0"s and integers zeroone and onezero. In one operation you can remove any substring "01" and receive zeroone points. Or you can remove any substring "10" and receive onezero points. Return the maximum number of points you can receive, given that you can make any number of operations. Constraints n ≤ 100,000 where n is the length of s Example 1 Input s = "101010" zeroone = 3 onezero = 1 Output 7 Explanation
View Solution →Maximize Rook Square Values - Google Top Interview Questions
You are given a two-dimensional list of integers board representing a chess board. Return the maximum sum you can attain by placing two rooks in the board such that they can't attack each other. The sum is made by adding the two numbers where the rooks are placed. Constraints 2 ≤ n * m ≤ 200,000 where n and m are the number of rows and columns in board Example 1 Input board = [ [1, 9, 3, 1, 9], [1, 1, 1, 1, 1], [8, 1, 1, 1, 1] ] Output 17 E
View Solution →Maximum Dropping Path Sum With Column Distance Cost - Google Top Interview Questions
You are given a two-dimensional list of integers matrix. You want to pick a number from each row. For each 0 ≤ r < n - 1 the cost for picking matrix[r][j] and matrix[r + 1][k] is abs(k - j). Return the maximum sum possible of the numbers chosen, minus costs. Constraints 1 ≤ n * m ≤ 200,000 where n and m are the number of rows and columns in matrix Example 1 Input matrix = [ [3, 2, 1, 6], [4, 1, 2, 0], [1, 5, 2, -2] ] Output 11 Explanation
View Solution →Maximum XOR Queries - Google Top Interview Questions
You are given a list of non-negative integers nums and a two-dimensional list of integers queries where each element contains [x, limit]. Return a list such that for each query [x, limit], we find an e in nums such that e ≤ limit and XOR(e, x) is maximized. If there's no such e, use -1. Constraints n ≤ 100,000 where n is the length of nums m ≤ 100,000 where m is the length of queries Example 1 Input nums = [2, 4, 8] queries = [ [3, 5], [2, 0] ] Output
View Solution →