javascript solution


  • 0
    F
    /**
     * @param {number} rowIndex
     * @return {number[]}
     */
    var getRow = function(rowIndex) {
        rowIndex=rowIndex+1;
        var result=[];
        for(var i=1;i<=rowIndex;i++){
            var array=[1];
            for(var j=1;j<i;j++){
                var num1=result[result.length-1][j];
                var num2=result[result.length-1][j-1];
                var num=num1?num1+num2:1;
                array.push(num);
            }
            result.push(array);
        }
        return result[result.length-1];
    };
    

Log in to reply
 

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