Skip to content

Commit 8ad0ece

Browse files
authored
Create missing_string.py
1 parent ce3b2bf commit 8ad0ece

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

missing_string.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# coding: utf-8
2+
3+
class Solution:
4+
"""
5+
@param: : a given string
6+
@param: : another given string
7+
@return: An array of missing string
8+
"""
9+
10+
def missingString(self, str1, str2):
11+
# Write your code here
12+
li_1 = str1.split(' ')
13+
li_2 = str2.split(' ')
14+
di = {}
15+
for word in li_2:
16+
if word not in di:
17+
di[word] = True
18+
ret = []
19+
for word in li_1:
20+
if word not in di:
21+
ret.append(word)
22+
return ret
23+
24+
# easy: http://lintcode.com/zh-cn/problem/missing-string/

0 commit comments

Comments
 (0)