[HackerRank][Python3] Tree: Huffman Decoding
2018. 7. 20. 22:41 |
프로그래밍/HackerRank
Problem :
https://www.hackerrank.com/challenges/tree-huffman-decoding/problem
My Solution :
#!/usr/bin/env python3 def decodeHuff(root, s): decoded = [] curr = root for ch in s: if ch == '1': curr = curr.right else: curr = curr.left if curr.data != '\0': decoded.append(curr.data) curr = root print(''.join(decoded))
'프로그래밍 > HackerRank' 카테고리의 다른 글
[HackerRank][Python3] Friend Circle Queries (0) | 2018.07.21 |
---|---|
[HackerRank][Python3] Time Complexity: Primality (0) | 2018.07.21 |
[HackerRank][Python3] Recursion: Davis' Staircase (0) | 2018.07.21 |
[HackerRank][Python3] Recursion: Fibonacci Numbers (0) | 2018.07.20 |
[HackerRank][Python3] Binary Search Tree : Lowest Common Ancestor (0) | 2018.07.20 |
[HackerRank][Python3] Balanced Brackets (0) | 2018.07.20 |
[HackerRank][Python3] Queues: A Tale of Two Stacks (0) | 2018.07.19 |
[HackerRank][Python3] Abbreviation (0) | 2018.07.18 |
최근에 달린 댓글 최근에 달린 댓글