Created
December 15, 2018 13:22
-
-
Save jsbonso/29d32c318cdd30a02f5001e086ebf856 to your computer and use it in GitHub Desktop.
Kth Element
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Write a method that finds k-th most common element in a list. For example, kthMostCommon(new in[]{5, 4, 3, 2, 1, 5, 4, 3, 2, 5, 4, 3, 5, 4, 5},2) should return 4. In the array, element 1 occurs once, 2 twice, 3 three times, 4 fours times, and 5 five times, making element 5 the most common element in the list and 4th the second most common element, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment