## Number of Non-Overlapping Sublists With Sum of Target - Google Top Interview Questions

You are given a list of integers nums and an integer target. Return the maximum number of non-overlapping, non-empty sublists that exist such that each sublist's sum is target. Constraints 0 ≤ n ≤ 100,000 where n is the length of nums Example 1 Input nums = [4, 3, 7, 5, -3, 10] target = 7 Output 3 Explanation We can have [4, 3], [7] and [-3, 10]

View Solution →## Number of Operations to Decrement Target to Zero - Google Top Interview Questions

You are given a list of positive integers nums and an integer target. Consider an operation where we remove a number v from either the front or the back of nums and decrement target by v. Return the minimum number of operations required to decrement target to zero. If it's not possible, return -1. Constraints n ≤ 100,000 where n is the length of nums Example 1 Input nums = [3, 1, 1, 2, 5, 1, 1] target = 7 Output 3 Explanation We can remove 1, 1 and 5 from the

View Solution →## Path to Maximize Probability to Destination - Google Top Interview Questions

You are given a two-dimensional list of integers edges, a list of floats success, and integers start and end. edges represents an undirected, weighted graph. Each edges[i] contains [u, v] meaning u and v is connected, and the chance of successfully traversing the edge is success[i] chance. Given that you start at node start and you want to arrive at node end, return the highest overall chance you can get by taking any path. If there's no path to end, return 0. Constraints 1 ≤ n ≤ 10

View Solution →## Peak Heights 🦖 - Google Top Interview Questions

You are given a two-dimensional integer matrix containing 0s and 1s where 0 represents water and 1 represents land. Return a new matrix of the same dimensions where we increase the height of every land cell as much as possible given that: The height of any water cell stays 0 Any cell can differ by at most 1 unit of height between neighboring cells (up, down, left, right) You can assume there is at least one water cell. Constraints n, m ≤ 250 where n and m are the number of rows

View Solution →## Peekable Iterator - Google Top Interview Questions

Implement an iterator of a list of integers nums where peek() returns the next element, without moving the iterator next() polls the next element in the iterator hasnext() which returns whether the next element exists Constraints n ≤ 100,000 where n is the number of calls to peek, next and hasnext Example 1 Input methods = ["constructor", "peek", "next", "hasnext", "peek", "next", "hasnext"] arguments = [[[1, 2]], [], [], [], [], [], []]` Output [None, 1, 1,

View Solution →