@john221 I think you misunderstood the question. In the case of [2,1], both elements '2' and '1' appears once so the degree of the array is 1. We need to find out a subarray that has the shortest length and the same degree of the input array.The 3 subarrays :[2,1], [1] and [2] has the same degree of [2,1], so the answer is 1 which is the length of [1] or [2].