(s, path, result)
| 12 | } |
| 13 | |
| 14 | const backtrack = (s, path, result) => { |
| 15 | if (s.length === 0) { |
| 16 | result.push([...path]) |
| 17 | return |
| 18 | } |
| 19 | |
| 20 | for (let i = 0; i < s.length; i++) { |
| 21 | const prefix = s.substring(0, i + 1) |
| 22 | if (palindrome(prefix)) { |
| 23 | path.push(prefix) |
| 24 | backtrack(s.substring(i + 1), path, result) |
| 25 | path.pop() |
| 26 | } |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | export default partitionPalindrome |
no test coverage detected