Given an integer array, return the length of the shortest contiguous subarray that contains every distinct value present in the whole array. Return 0 if the array is empty. Input: an integer array.
Input: An integer array.
Output: Integer — shortest qualifying subarray length.
Input: [1,2,2,3,1]
Output: 4
Explanation: Subarray [2,3,1] is too short on distinct... shortest containing {1,2,3} is [1,2,2,3] length 4? Actually [2,3,1] (indices 2-4) contains 2,3,1 = all 3 distinct, length 3.Input: [1,1,1]
Output: 1
Explanation: Only one distinct value.0<=n<=10^5-10^9<=nums[i]<=10^9