Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from collections import defaultdict
- class Solution(object):
- def findLongestWord(self, s, d):
- """
- :type s: str
- :type d: List[str]
- :rtype: str
- """
- return min(filter(lambda x: self.is_subseq(x, s), d) + [''],
- key=lambda ans: (-len(ans), ans)
- )
- def is_subseq(self, word, s):
- it = iter(s)
- return all(char in it for char in word)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement