Leetcode Pascal's Triangle II
2015-05-18 17:51
423 查看
动规求Pascal三角,0ms简单动规
int* getRow(int rowIndex, int* returnSize) {
int i, j;
*returnSize = rowIndex + 1;
int* a = calloc(sizeof(int), (rowIndex + 1));
a[0] = 1;
for (i = 1 ; i <= rowIndex ; i++)
for (j = i ; j >= 1 ; j--)
a[j] += a[j-1];
return a;
}
int* getRow(int rowIndex, int* returnSize) {
int i, j;
*returnSize = rowIndex + 1;
int* a = calloc(sizeof(int), (rowIndex + 1));
a[0] = 1;
for (i = 1 ; i <= rowIndex ; i++)
for (j = i ; j >= 1 ; j--)
a[j] += a[j-1];
return a;
}
相关文章推荐
- leetcode Pascal's Triangle II
- LeetCode之Pascal's Triangle II
- leetcode--Pascal's Triangle && ii
- Leetcode Pascal's Triangle II
- 【LeetCode】119. Pascal's Triangle II
- leetcode -day13 Valid Palindrome & Triangle & Pascal's Triangle I II
- [Leetcode]119. Pascal's Triangle II
- leetcode: Pascal's Triangle II
- [C语言] leetcode 119. Pascal's Triangle II
- [Leetcode从零开刷]119. Pascal's Triangle II
- [leetcode, python] Pascal's Triangle II 杨辉三角
- LeetCode 119. Pascal's Triangle II
- leetcode-pascal triangle I&&II
- Pascal's Triangle II-leetcode
- LeetCode---(119)Pascal's Triangle II
- LeetCode 119. Pascal's Triangle II
- LeetCode119—Pascal's Triangle II
- Leetcode Pascal's Triangle II
- LeetCode Pascal's Triangle II
- [leetcode, python] Pascal's Triangle II 杨辉三角