1708. Largest Subarray Length K
https://leetcode.com/problems/largest-subarray-length-k
Description
An array A
is larger than some array B
if for the first index i
where A[i] != B[i]
, A[i] > B[i]
.
For example, consider 0
-indexing:
[1,3,2,4] > [1,2,2,4]
, since at index1
,3 > 2
.[1,4,4,4] < [2,1,1,1]
, since at index0
,1 < 2
.
A subarray is a contiguous subsequence of the array.
Given an integer array nums
of distinct integers, return the largest subarray of nums
of length k
.
Example 1:
Example 2:
Example 3:
Constraints:
1 <= k <= nums.length <= 105
1 <= nums[i] <= 109
All the integers of
nums
are unique.
Follow up: What if the integers in nums
are not distinct?
ac
Last updated