Company: Publicis Sapient
Difficulty: medium
Degree of an Array You are given an array nums of n non-negative integers. The degree of an array is the largest number of times any single value occurs in it. Find the length of the shortest contiguous subarray of nums whose degree is equal to the degree of the whole array. Function description Complete the function findShortestSubarray with the following parameter: INTEGER_ARRAY nums : the array of values Returns INTEGER : the length of the shortest contiguous subarray of nums that has the same degree as nums . Input format The first line contains the integer n , the number of elements. The second line contains n space-separated integers nums[0], nums[1], ..., nums[n-1] . Output format Print a single integer: the length of the shortest such subarray. Constraints 1 <= n <= 20000 (inferred -- the source screen gives no bound for n ; this one keeps every input within the judge's input limit.) 0 <= nums[i] <= 10^6 (inferred -- the source only says the values are non-negative