Advertisement
Guest User

Untitled

a guest
Sep 20th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.43 KB | None | 0 0
  1. from collections import defaultdict
  2. class Solution(object):
  3.     def findLongestWord(self, s, d):
  4.         """
  5.        :type s: str
  6.        :type d: List[str]
  7.        :rtype: str
  8.        """
  9.         return min(filter(lambda x: self.is_subseq(x, s), d) + [''],
  10.             key=lambda ans: (-len(ans), ans)
  11.         )
  12.        
  13.     def is_subseq(self, word, s):
  14.         it = iter(s)
  15.         return all(char in it for char in word)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement