Skip to content

Commit c03a5fa

Browse files
committed
[LC] feat: 240824 encode-and-decode-string
1 parent 63a05ff commit c03a5fa

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

encode-and-decode-strings/hajunyoo.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
class Solution1:
2+
"""
3+
@param: strs: a list of strings
4+
@return: encodes a list of strings to a single string.
5+
"""
6+
# time complexity: O(n)
7+
# space complexity: O(1)
8+
def encode(self, strs):
9+
return ":;".join(strs)
10+
11+
"""
12+
@param: str: A string
13+
@return: decodes a single string to a list of strings
14+
"""
15+
# time complexity: O(n)
16+
# space complexity: O(1)
17+
def decode(self, str):
18+
return str.split(":;")

0 commit comments

Comments
 (0)