Another Improbable Challenge Question


  • 0
    H

    For a set of numbers (e.g. {1, 2, 2, 2, 3, 4, 1, 5, 1, 6}) the degree of the set is the largest number of occurences of the same element. In the given example the degree is 3 as both element 1 and element 2 occur 3 times each.

    Given a set of numbers, return the length of the smallest subset that has the same degree as the original set. For the given example, the two subsets with the same degree as the original set are {1, 2, 2, 2, 3, 4, 1, 5, 1} and {2, 2, 2}. The first subset is 9 elements long and the second one is 3 elements long, so the program should return 3.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.