my javascript solution


  • 0
    L
    var convert = function (s, numRows) {
        var str = "";
        if (numRows === 1)
            return s;
        for (var i = 0; i < numRows; i++) {
            var leep = 2 * numRows - 2 - 2 * i;
            for (var j = i; j < s.length;) {
                if (leep !== 0)
                    str += s[j];
                j += leep;
                if (leep !== (2 * numRows - 2))
                    leep = 2 * numRows - 2 - leep;
            }
        }
        return str;
    };
    

    any better solution?


Log in to reply
 

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