Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7a0b866

Browse files
authored
Merge pull request #2 from ranamabdullah/main
sone new algo added
2 parents 51e6af3 + 6b44083 commit 7a0b866

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#Given two sentences, return an array that has the words that appear in one sentence and not
2+
#the other and an array with the words in common.
3+
4+
sentence1 = 'We are really pleased to meet you in our city'
5+
sentence2 = 'The city was hit by a really heavy storm'
6+
7+
def solution(sentence1, sentence2):
8+
set1 = set(sentence1.split())
9+
set2 = set(sentence2.split())
10+
11+
return sorted(list(set1^set2)), sorted(list(set1&set2)) # ^ A.symmetric_difference(B), & A.intersection(B)
12+
13+
print(solution(sentence1, sentence2))

Other Algorithms/Reverse_Integer.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Given an integer, return the integer with reversed digits.
2+
# Note: The integer could be either positive or negative.
3+
4+
def solution(x):
5+
string = str(x)
6+
7+
if string[0] == '-':
8+
return int('-'+string[:0:-1])
9+
else:
10+
return int(string[::-1])
11+
12+
print(solution(-231))
13+
print(solution(345))

0 commit comments

Comments
 (0)