Uber logoUber
Coding·90 minMembers

OA: Shortest Subarray with At Least K Distinct

Members only

Hack2Hire OA problem. Given an array `arr` and integer `k`, find the length of the shortest contiguous subarray that contains at least `k` distinct integers. Return `−1` if no such subarray exists.

SWE
two-pointer
hashmap
medium
Frequency
Low
Last asked
2026-04-01
Stage
oa

Log in to continue reading the full content

Comments

Sign in to join the discussion
Loading...