#3471

Find the Largest Almost Missing Integer

easy · 37.1% accepted · 107 likes · top 15%

array · hash table

⊣ practice⊣ open on leetcode ↗

Description

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.

A subarray is a contiguous sequence of elements within an array.

Solution