Skip to content

Commit b5d657e

Browse files
authored
Uncommon Words from Two Sentences
1 parent 52a98d7 commit b5d657e

File tree

1 file changed

+25
-0
lines changed
  • 884. Uncommon Words from Two Sentences

1 file changed

+25
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Solution
2+
```
3+
class Solution:
4+
def uncommonFromSentences(self, A, B):
5+
A = A.split()
6+
B = B.split()
7+
di = dict()
8+
for x in range(len(A)):
9+
if A[x] in di:
10+
di[A[x]] += 1
11+
else:
12+
di[A[x]] = 1
13+
14+
for x in range(len(B)):
15+
if B[x] in di:
16+
di[B[x]] += 1
17+
else:
18+
di[B[x]] = 1
19+
20+
out = []
21+
for (key, value) in di.items():
22+
if value == 1:
23+
out.append(key)
24+
return out
25+
```

0 commit comments

Comments
 (0)