/** * @param {number} n * @return {string[]} */ var generateParenthesis = function(n) { let str = 1.0.toFixed(n).substr(2).replace(/0/g, '(') let _case = [] let result = [] //console.log(str, _case) let num = n //剩下的 let m = n let i = 0 while(i < n){ i++ } for(let j=n; j>=0; j--){ _case.push( str.substr(0, j) ) num -= j } return result }; try{ console.log(generateParenthesis(5)) }catch(e){ console.log(e) }