Skip to content

Commit efdefa1

Browse files
committed
feat: Encode and Decode Strings
1 parent ad8a118 commit efdefa1

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* https://www.lintcode.com/problem/659/
3+
* Time Complexity: O(n)
4+
* Space Complexity: O(n)
5+
*/
6+
7+
function encode(strs: string[]): string {
8+
return strs.join("😀");
9+
}
10+
11+
function decode(str: string): string[] {
12+
return str.split("😀");
13+
}
14+
15+
decode(encode(["Hello", "World"]));
16+
/*
17+
* output
18+
* ["Hello","World"]
19+
*/

0 commit comments

Comments
 (0)