We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 173cf0f commit 5420d07Copy full SHA for 5420d07
encode-and-decode-strings/kayden.py
@@ -0,0 +1,29 @@
1
+class Solution:
2
+
3
+ # 시간복잡도: O(N)
4
+ # 공간복잡도: O(1)
5
+ def encode(self, strs):
6
+ res = ""
7
+ for str in strs:
8
+ size = len(str)
9
+ res += str(size)
10
+ res += str
11
12
+ return res
13
14
15
+ # 공간복잡도: O(N)
16
+ def decode(self, str):
17
+ idx = 0
18
+ limit = len(str)
19
+ res = []
20
21
+ while idx < limit:
22
+ num = str[idx]
23
+ text = ""
24
+ for _ in range(num):
25
+ text += str[idx]
26
+ idx+=1
27
+ res.append(text)
28
29
0 commit comments