11 lines
524 B
Python
11 lines
524 B
Python
def find_max(words):
|
|
"""Write a function that accepts a list of strings.
|
|
The list contains different words. Return the word with maximum number
|
|
of unique characters. If multiple strings have maximum number of unique
|
|
characters, return the one which comes first in lexicographical order.
|
|
|
|
find_max(["name", "of", "string"]) == "string"
|
|
find_max(["name", "enam", "game"]) == "enam"
|
|
find_max(["aaaaaaa", "bb" ,"cc"]) == ""aaaaaaa"
|
|
"""
|
|
return sorted(words, key=lambda x: (-len(set(x)), x))[0] |