--DAY 16--
Hi, I am going to make #100DaysOfCode Challenge. Everyday I will try solve 1 problem from leetcode or hackerrank. Hope you can go with me until end.
Now let's solve problem today:
var getRow = function(index) {
if(index==0) return [1];
if(index==1) return [1,1];
let ans=[[1],[1,1]];
for(let i=2;i<=index;i++){
let tmp=[];
tmp[0]=1;
for(let j=1;j<i+1;j++){
tmp[j]=ans[i-1][j-1]+ans[i-1][j];
}
tmp[i]=1;
ans.push(tmp);
}
return ans[index];
};
-->If you have better solution or any question, please comment below. I will appreciate.
Top comments (1)
thanks you !