javascript solution


  • 0
    W
    /**
     * @param {string} s
     * @param {number} numRows
     * @return {string}
     */
    var convert = function(s, numRows) {
        var y=0;
        var storeArr=[];
        if(numRows==1){
            return s;
        }
        for(var i=0;i<s.length;i++){
            storeArr[y]=(storeArr[y]||"")+""+s[i];
            y==0?(flag=true):"";
            y==(numRows-1)?(flag=false):"";
            flag?y++:y--;
        }
        return storeArr.join("");
    };
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.