Skip to content

Commit 6230c4a

Browse files
committed
Add week 5 soultions : encodeAndDecodeStrings
1 parent ba05d0e commit 6230c4a

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Time Complexity: O(n), O(n)
2+
// Space Complexity: O(n), O(n)
3+
4+
class Solution {
5+
encode(strs) {
6+
// join the array into a single string using a delimiter, '|'.
7+
return strs.join('|');
8+
}
9+
10+
decode(str) {
11+
// split the string using the delimiter '|' and return the array.
12+
return str.split('|');
13+
}
14+
}

0 commit comments

Comments
 (0)