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 649197a commit 9bdaebbCopy full SHA for 9bdaebb
encode-and-decode-strings/printjin-gmailcom.py
@@ -0,0 +1,18 @@
1
+class Solution:
2
+ def encode(self, strs):
3
+ res = ''
4
+ for s in strs:
5
+ res += str(len(s)) + '#' + s
6
+ return res
7
+
8
+ def decode(self, s):
9
+ res = []
10
+ i = 0
11
+ while i < len(s):
12
+ j = i
13
+ while s[j] != '#':
14
+ j += 1
15
+ length = int(s[i:j])
16
+ res.append(s[j+1:j+1+length])
17
+ i = j + 1 + length
18
0 commit comments