Skip to content

slash-generate

Posted on:June 16, 2023 at 06:05 AM

回溯算法

生成组合 => 有多少组。。。 1 对括号 () 2 对括号 ()() (()) 3 对括号 ()()() (()()) (())() ()(()) ((()))

left right

1 (((

const l = [{ current: ”, left: 3, right: 3, } ] const fun = (l) => {

l.forEach()

while()//

}

interface A { current: str; left: num right: num }

const back = (item, left, right, jobs) => {

if(left ===0 && right ===0 ) {
    return item
}


if(left.length > 0 ) {
jobs.push({
current: item.current + "("
left: left -1
right: right
})
}


if(right.length > 0 && right.length > left.length ) {
jobs.push({
current: item.current + "("
left: left
right: right -1,
})
}

return;

}

https://leetcode-solution-leetcode-pp.gitbook.io/leetcode-solution/medium/22.generate-parentheses