Skip to content

Practice Find the Largest Almost Missing Integer

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#3471
LeetCode Problem

Find the Largest Almost Missing Integer

Problem Statement

You are given an integer array nums and an integer k. An integer x is almost missing from nums if x appears in exactly one subarray of size k within nums. Return the largest almost missing integer from nums. If no such integer exists, return -1.

Source: Find the Largest Almost Missing Integer on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
nums = [3,9,2,1,7], k = 3
Output
7

# Example 2

Input
nums = [3,9,7,2,1,7], k = 4
Output
3

# Example 3

Input
nums = [0,0], k = 1
Output
-1

Constraints

1 <= nums.length <= 50
0 <= nums[i] <= 50
1 <= k <= nums.length

Related LeetCode Problems

Practice more problems similar to Find the Largest Almost Missing Integer.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.