Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb5d657e

Browse files
authored
Uncommon Words from Two Sentences
1 parent52a98d7 commitb5d657e

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)

[8]ページ先頭

©2009-2025 Movatter.jp