1002. 查找常用字符
给定仅有小写字母组成的字符串数组 A,返回列表中的每个字符串中都显示的全部字符(包括重复字符)组成的列表。例如,如果一个字符在每个字符串中出现 3 次,但不是 4 次,则需要在最终答案中包含该字符 3 次。
你可以按任意顺序返回答案。
思路:用了个比较python的双列表存储的办法解决
class Solution:
def commonChars(self, A: List[str]) -> List[str]:
temp_a,temp_b = [],[]
if not A:
return []
for _ in A[0]:
temp_a.append(_)
for i in range(1,len(A)):
for _ in A[i]:
if _ in temp_a:
temp_a.remove(_)
temp_b.append(_)
temp_a,temp_b = temp_b,[]
return temp_a