> For the complete documentation index, see [llms.txt](https://jaywin.gitbook.io/leetcode/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jaywin.gitbook.io/leetcode/solutions/1708-largest-subarray-length-k.md).

# 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 index `1`, `3 > 2`.
* `[1,4,4,4] < [2,1,1,1]`, since at index `0`, `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:**

```
**Input:** nums = [1,4,5,2,3], k = 3
**Output:** [5,2,3]
**Explanation:** The subarrays of size 3 are: [1,4,5], [4,5,2], and [5,2,3].
Of these, [5,2,3] is the largest.
```

**Example 2:**

```
**Input:** nums = [1,4,5,2,3], k = 4
**Output:** [4,5,2,3]
**Explanation:** The subarrays of size 4 are: [1,4,5,2], and [4,5,2,3].
Of these, [4,5,2,3] is the largest.
```

**Example 3:**

```
**Input:** nums = [1,4,5,2,3], k = 1
**Output:** [5]
```

**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

```java
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://jaywin.gitbook.io/leetcode/solutions/1708-largest-subarray-length-k.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
