Python arrays

The weight of an array is defined as the maximum number of occurrences of any integer in the array.
Given an array of positive integers ‘k’,find the smallest possible length of a subarray of the array ‘k’ that has the same weight as ‘k’.integers should remain contiguous in the subarray

k.length will be between 1 and 50,000
k[i] will be an integer between 0 and 49,999

Is this an exam question?

If not, please follow these guidelines when asking a question: