Skip to content

Commit da96545

Browse files
committed
[Week5](gmlwls96) Encode And Decode String
1 parent 1e91ae8 commit da96545

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
class Solution {
2+
3+
fun encode(strs: List<String>): String {
4+
return strs.joinToString(separator = ":;") {
5+
if (it == ":") {
6+
"::"
7+
} else {
8+
it
9+
}
10+
}
11+
}
12+
13+
fun decode(str: String): List<String> {
14+
return str
15+
.replace("::", ":")
16+
.split(":;")
17+
}
18+
}

0 commit comments

Comments
 (0)