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

Commit 7c49468

Browse files
It's not over yet.
1 parent defc4ea commit 7c49468

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
""" https://leetcode.com/problems/uncommon-words-from-two-sentences/ """
2+
3+
class Solution:
4+
def uncommonFromSentences(self, s1, s2):
5+
uncommonWords = []
6+
s1 = s1.split()
7+
s2 = s2.split()
8+
9+
if (len(s1) >= len(s2)):
10+
string = s2
11+
else:
12+
string = s1
13+
14+
for word in string:
15+
pieceS1 = s1.count(word)
16+
17+
print("başta", word)
18+
19+
if (pieceS1 > 1):
20+
continue
21+
else:
22+
pieceS2 = s2.count(word)
23+
24+
if (pieceS2 > 0):
25+
continue
26+
else:
27+
uncommonWords.append(word)
28+
29+
print("sonda", word)
30+
31+
32+
33+
return uncommonWords
34+
35+
print(Solution().uncommonFromSentences("this apple is sweet", "this apple is sour"))

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /