File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
encode-and-decode-strings Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 1+ /**
2+ * @description ๋ฌธ์์ด ๋ฐฐ์ด์ ํ๋์ ๋ฌธ์์ด๋ก ์ธ์ฝ๋ฉํฉ๋๋ค.
3+ * @param {string[] } strs - ๋ฌธ์์ด ๋ฐฐ์ด
4+ * @returns {string } ์ธ์ฝ๋ฉ๋ ๋ฌธ์์ด
5+ *
6+ * ์๊ฐ ๋ณต์ก๋: O(N)
7+ * - N์ ์
๋ ฅ ๋ฐฐ์ด์ ๋ชจ๋ ๋ฌธ์์ด ๊ธธ์ด์ ํฉ
8+ * ๊ณต๊ฐ ๋ณต์ก๋: O(1)
9+ * - ์ถ๊ฐ ๋ฉ๋ชจ๋ฆฌ ์ฌ์ฉ ์์
10+ */
11+ function encode ( strs : string [ ] ) : string {
12+ return strs . join ( ':' ) ;
13+ }
14+
15+ /**
16+ * @description ์ธ์ฝ๋ฉ๋ ๋ฌธ์์ด์ ๋ค์ ๋ฌธ์์ด ๋ฐฐ์ด๋ก ๋์ฝ๋ฉํฉ๋๋ค.
17+ * @param {string } s - ์ธ์ฝ๋ฉ๋ ๋ฌธ์์ด
18+ * @returns {string[] } ๋์ฝ๋ฉ๋ ๋ฌธ์์ด ๋ฐฐ์ด
19+ *
20+ * ์๊ฐ ๋ณต์ก๋: O(N)
21+ * - N์ ์
๋ ฅ ๋ฌธ์์ด์ ๊ธธ์ด
22+ * ๊ณต๊ฐ ๋ณต์ก๋: O(1)
23+ * - ์ถ๊ฐ ๋ฉ๋ชจ๋ฆฌ ์ฌ์ฉ ์์
24+ */
25+ function decode ( s : string ) : string [ ] {
26+ return s . split ( ':' ) ;
27+ }
28+
You canโt perform that action at this time.
0 commit comments