1 /** 2 * @param {string} s 3 * @param {number} numRows 4 * @return {string} 5 */ 6 var convert = function (s, numRows) { 7 if (numRows === 1) { 8 return s; 9 } 10 11 let ans = ""; 12 const n = s.length; 13 const r = numRows; 14 const t = r * 2 - 2; 15 16 for (let i = 0; i < r; i++) { 17 for (let j = 0; j + i < n; j += t) { 18 ans += s[j + i]; 19 if (i > 0 && i < r - 1 && j + t - i < n) { 20 ans += s[j + t - i]; 21 } 22 } 23 } 24 25 return ans; 26 };
标签:return,字形,变换,param,numRows,let,ans,const From: https://www.cnblogs.com/yadayou/p/17848331.html