Skip to content

Commit b244621

Browse files
committedMay 17, 2023
✨ [394] Decode String
1 parent 65e6547 commit b244621

File tree

4 files changed

+46
-2
lines changed

4 files changed

+46
-2
lines changed
 

‎394/README.md

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
https://leetcode.com/problems/decode-string/
2+
3+
Given an encoded string, return its decoded string.
4+
5+
The encoding rule is: `k[encoded_string]`, where the `encoded_string` inside the square brackets is being repeated exactly `k` times. Note that `k` is guaranteed to be a positive integer.
6+
7+
You may assume that the input string is always valid; there are no extra white spaces, square brackets are well-formed, etc. Furthermore, you may assume that the original data does not contain any digits and that digits are only for those repeat numbers, `k`. For example, there will not be input like `3a` or `2[4]`.
8+
9+
The test cases are generated so that the length of the output will never exceed `105`.
10+
11+
**Example 1:**
12+
13+
```
14+
Input: s = "3[a]2[bc]"
15+
Output: "aaabcbc"
16+
```
17+
18+
**Example 2:**
19+
20+
```
21+
Input: s = "3[a2[c]]"
22+
Output: "accaccacc"
23+
```
24+
25+
**Example 3:**
26+
27+
```
28+
Input: s = "2[abc]3[cd]ef"
29+
Output: "abcabccdcdcdef"
30+
```
31+
32+
**Constraints:**
33+
34+
- `1 <= s.length <= 30`
35+
- `s` consists of lowercase English letters, digits, and square brackets `'[]'`.
36+
- `s` is guaranteed to be **a valid** input.
37+
- All the integers in `s` are in the range `[1, 300]`.

‎394/my_solution.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* @param {string} s
3+
* @return {string}
4+
*/
5+
const decodeString = (s) => {
6+
7+
};

‎394/solution.js

Whitespace-only changes.

‎README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
- [7. Generate Parentheses](./7/)
99
- [15. 3Sum](./15/)
1010
- [200. Number of Islands](./200/)
11+
- [394. Decode String](./394/)
1112

1213
---
1314

@@ -36,6 +37,5 @@ iex ./.../solution.ex
3637

3738
Quick create in bash
3839
```ssh
39-
chapter=15
40-
mkdir ./$chapter && touch ./$chapter/README.md && touch ./$chapter/my_solution.js && touch ./$chapter/solution.js
40+
chapter=394 && mkdir ./$chapter && touch ./$chapter/README.md && touch ./$chapter/my_solution.js && touch ./$chapter/solution.js
4141
```

0 commit comments

Comments
 (0)
Please sign in to comment.