Skip to content

Commit 4b11e52

Browse files
committed
feat: Encode and Decode Strings
1 parent ebca97f commit 4b11e52

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

encode-and-decode-strings/HodaeSsi.py

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# 시간복잡도: O(n)
2+
# 공간복잡도: O(1)
3+
4+
class Solution:
5+
"""
6+
@param: strs: a list of strings
7+
@return: encodes a list of strings to a single string.
8+
"""
9+
def encode(self, strs):
10+
if not strs:
11+
return ""
12+
return chr(257).join(strs)
13+
14+
"""
15+
@param: str: A string
16+
@return: decodes a single string to a list of strings
17+
"""
18+
def decode(self, str):
19+
if not str:
20+
return []
21+
return str.split(chr(257))
22+

0 commit comments

Comments
 (0)