Back to problems

Find a Bounded Subarray and Largest Square

Algorithm · Uber · Hard

Complete the following two independent tasks. Problem 1 Let nums be an array of integers and limit be a nonnegative integer. Return the maximum number of elements that can appear in one contiguous block of nums if the block's largest and smallest elements may differ by no more than limit. Example 1: Explanation: The longest valid blocks are [1, 3] and [2, 5], both containing two elements. Example 2: Explanation: The block [4, 5, 3, 6] has largest value 6 and smallest value…

Checking your access…