Skip to content

Commit

Permalink
Unique Morse codes'
Browse files Browse the repository at this point in the history
  • Loading branch information
BravesDevs committed Jan 26, 2024
1 parent 5cbb295 commit afc1e0b
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lc/Python/diagonalSort.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class Solution:
def diagonalSort(self, mat):
startRow = len(mat)-1
startCol = 0

while startRow >= 0 and startCol < len(mat[0]):
count = 0
while count:
print(mat[startRow][startRow+count])

startRow -= 1


sln = Solution([[1, 3, 1], [2, 2, 1], [1, 1, 1]])
23 changes: 23 additions & 0 deletions lc/Python/uniqueMorseRepresentations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
class Solution:
def uniqueMorseRepresentations(self, words):
MORSE_CODE_DICT = {'A': '.-', 'B': '-...',
'C': '-.-.', 'D': '-..', 'E': '.',
'F': '..-.', 'G': '--.', 'H': '....',
'I': '..', 'J': '.---', 'K': '-.-',
'L': '.-..', 'M': '--', 'N': '-.',
'O': '---', 'P': '.--.', 'Q': '--.-',
'R': '.-.', 'S': '...', 'T': '-',
'U': '..-', 'V': '...-', 'W': '.--',
'X': '-..-', 'Y': '-.--', 'Z': '--..'}
uniqueCodes = set()
for i in words:
st = ""
for j in i:
st += MORSE_CODE_DICT[j.upper()]
uniqueCodes.add(st)

return len(uniqueCodes)


sln = Solution()
print(sln.uniqueMorseRepresentations(["gin", "zen", "gig", "msg"]))

0 comments on commit afc1e0b

Please sign in to comment.