''' Write a method highestRank(arr) (or highest-rank in clojure) which returns the number which is most frequent in the given input array (or ISeq). If there is a tie for most frequent number, return the largest number of which is most frequent. 翻译:输出字典中出现次数最多的,如果次数相同则输出值最大的 '''
自己
'''
解题思路:
1、使用sorted函数排列列表,定义key,将列表中该字符串出现的次数加权
2、使用切片,取最后一个
'''
def highest_rank(arr):
return sorted(arr, key=lambda c: (arr.count(c), c))[-1]
因为今天写的这个已经是最简单的了,和最佳答案一模一样就不贴最佳答案了。