Skip to content

Commit

Permalink
Find Common Characters
Browse files Browse the repository at this point in the history
  • Loading branch information
24rochak committed Jul 20, 2019
1 parent a32d57b commit e5413de
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Find Common Characters.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
def commonChars(A):
"""
:type A: List[str]
:rtype: List[str]
"""
unique = set(A[0])
ans = []
for item in unique:
temp = []
for word in A:
temp.append(word.count(item))
ans.extend([item] * min(temp))

return ans


A = ["roller", "bella", "label"]
# A = ["acabcddd","bcbdbcbd","baddbadb","cbdddcac","aacbcccd","ccccddda","cababaab","addcaccd"]
ans = commonChars(A)
print(ans)

0 comments on commit e5413de

Please sign in to comment.