Skip to content

Commit 509551d

Browse files
authored
Merge pull request #133 from ashwek/Reverse
0804 & 0657 - Python
2 parents 5eb4cff + 757b5e3 commit 509551d

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
class Solution:
2+
def judgeCircle(self, moves):
3+
"""
4+
:type moves: str
5+
:rtype: bool
6+
"""
7+
8+
x = 0
9+
y = 0
10+
for each in moves:
11+
if( each == 'U' ):
12+
y += 1
13+
elif( each == 'D' ):
14+
y -= 1
15+
elif( each == 'R' ):
16+
x += 1
17+
elif( each == 'L' ):
18+
x -= 1
19+
20+
return x == y == 0
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Solution:
2+
def uniqueMorseRepresentations(self, words):
3+
"""
4+
:type words: List[str]
5+
:rtype: int
6+
"""
7+
8+
morse_code = [".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..", ".---", "-.-", ".-..", "--", "-.", "---", ".--.", "--.-", ".-.", "...", "-", "..-", "...-", ".--", "-..-", "-.--", "--.."]
9+
10+
unique = {}
11+
for each in words:
12+
unique["".join(morse_code[ord(ch)-97] for ch in each)] = 0
13+
14+
return len(unique)

0 commit comments

Comments
 (0)