(str, index = 0, decodedWords = [])
| 21 | * @return {string[]} |
| 22 | */ |
| 23 | var decode = (str, index = 0, decodedWords = []) => { |
| 24 | while (index < str.length) { |
| 25 | /* Time O(N) */ |
| 26 | const { nextIndex, word } = delimitWord( |
| 27 | str, |
| 28 | index, |
| 29 | ); /* Time O(K) | Ignore Auxillary Space Space (K) */ |
| 30 | |
| 31 | decodedWords.push( |
| 32 | word, |
| 33 | ); /* | Ignore Auxillary Space O(N * K ) */ |
| 34 | index = nextIndex; |
| 35 | } |
| 36 | |
| 37 | return decodedWords; |
| 38 | }; |
| 39 | |
| 40 | const delimitWord = (str, index) => { |
| 41 | const delimiter = str.indexOf('#', index); /* Time O(K) */ |
nothing calls this directly
no test coverage detected