This content originally appeared on DEV Community and was authored by duccanhole
--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.
This content originally appeared on DEV Community and was authored by duccanhole
![](https://www.radiofree.org/wp-content/plugins/print-app/icon.jpg)
duccanhole | Sciencx (2021-11-10T01:36:51+00:00) code every day with me. Retrieved from https://www.scien.cx/2021/11/10/code-every-day-with-me-4/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.