Closed yuewanxinghui closed 1 month ago
const fn = (num) => { const res = [] let i = 1 const temp = Math.ceil(num.toString().split('').length / 2) let maxNum = Number(1${[...Array(temp).keys()].map(i => '0').join('')}) const reverseFn = (n) => n.toString().split('').reverse().join('') const tempArr = [...Array(10).keys()] while (i < maxNum) { if (i < 10) { res.push(Number(${i}${i})) } else { const reNum = Number(${i}${reverseFn(i)}) if (reNum < num) { res.push(reNum) } } for(let j = 0; j < 10; j++) { const reNum = Number(${i}${j}${reverseFn(i)}) if (reNum < num) { res.push(reNum) } } i++ } return res }
1${[...Array(temp).keys()].map(i => '0').join('')}
${i}${i}
${i}${reverseFn(i)}
${i}${j}${reverseFn(i)}
const fn = (num) => { const res = [] let i = 1 const temp = Math.ceil(num.toString().split('').length / 2) let maxNum = Number(
1${[...Array(temp).keys()].map(i => '0').join('')}
) const reverseFn = (n) => n.toString().split('').reverse().join('') const tempArr = [...Array(10).keys()] while (i < maxNum) { if (i < 10) { res.push(Number(${i}${i}
)) } else { const reNum = Number(${i}${reverseFn(i)}
) if (reNum < num) { res.push(reNum) } } for(let j = 0; j < 10; j++) { const reNum = Number(${i}${j}${reverseFn(i)}
) if (reNum < num) { res.push(reNum) } } i++ } return res }