title-img


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 →

Minimize Maximum Stadium Size - Google Top Interview Questions

You are given an integer n and a two-dimensional list of integers views. There are n teams in a tournament and you want to build two stadiums to host the games. Each element in views contains [a, b, people] meaning that when team a and team b compete, there are people number of people that will view that game. The viewership numbers among every pair of teams will be in views. You must permanently assign each team to a stadium. Every team in a stadium plays every other team in that

View Solution →