## Sum of Sublist Range Sum - Google Top Interview Questions

You are given a list of non-negative integers nums and integers i and j. Let A be a sorted list of the sum of every sublist of nums. Return the sum of A from [i, j], inclusive. Constraints 1 ≤ n ≤ 100,000 where n is the length of nums Example 1 Input nums = [1, 2, 3, 4] i = 2 j = 3 Output 6 Explanation A = [1, 2, 3, 3, 4, 5, 6, 7, 9, 10] here and sum([3, 3]) = 6.

View Solution →## Toggle Bitwise Expression - Google Top Interview Questions

You are given a string s representing a bitwise expression with the following characters: "0", "1", "&", "|", "(", and ")". In one operation, you can: Toggle "0" to "1" Toggle "1" to "0" Change "&" to "|" Change "|" to "&" Return the minimum number of operations required to toggle the value of the expression. Note: the precedence of the operators don't matter, since they'll be wrapped in brackets when necessary. For example, "1&0" and "1&(0&1)" are possible input

View Solution →## Turn Into Non-Increasing List - Google Top Interview Questions

You are given a list of integers nums. Consider an operation where we take two consecutive integers and merge it into one by taking their sum. Return the minimum number of operations required so that the list becomes non-increasing. Constraints n ≤ 1,000 where n is the length of nums. Example 1 Input nums = [1, 5, 3, 9, 1] Output 2 Explanation We can merge [1, 5] to get [6, 3, 9, 1] and then merge [6, 3] to get [9, 9, 1]. Example 2 Input nums = [3]

View Solution →## Towers Without a Valley - Google Top Interview Questions

You are given a list of integers nums. Consider a list of integers A such that A[i] ≤ nums[i]. Also, there are no j and k such that there exist j < i < k and A[j] > A[i] and A[i] < A[k]. Return the maximum possible sum of A. Constraints 1 ≤ n ≤ 100,000 where n is the length of nums Example 1 Input nums = [10, 6, 8] Output 22 Explanation We can create A = [10, 6, 6]. Example 2 Input nums = [4, 5, 1, 1, 5] Output 12 Explanation We can create A

View Solution →## Unique Paths to Go Home - Google Top Interview Questions

You are given a two-dimensional list of integers edges where each element contains [u, v, distance] representing a weighted undirected graph. You are currently at node 0 and your home is the largest node. You can go from u to v if it's immediately connected and the shortest distance from u to home is larger than the shortest distance from v to home. Return the number of unique paths possible to go from node 0 to home. Mod the result by 10 ** 9 + 7. Constraints 1 ≤ n ≤ 100,000 where n is

View Solution →