Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution:
- def commonChars(self, words: List[str]) -> List[str]:
- a = min(words)
- words.remove(a)
- for char in a[:]: # shallow copy by slice
- for i, word in enumerate(words):
- if char not in word and (i == len(words) or char in a):
- a =a.replace(char, "", 1)
- break
- else:
- words[i] = words[i].replace(char, "", 1)
- return a
Advertisement
Add Comment
Please, Sign In to add comment