File tree 2 files changed +33
-2
lines changed
2 files changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -75,7 +75,7 @@ them with C++ Language.
75
75
| 122 | [ Best Time to Buy and Sell Stock II] | [ C] ( src/122.c ) |
76
76
| 121 | [ Best Time to Buy and Sell Stock] | [ C] ( src/121.c ) |
77
77
| 120 | [ Triangle] | [ C] ( src/120.c ) |
78
- | 119 | [ Pascal's Triangle II] | |
78
+ | 119 | [ Pascal's Triangle II] | [ C ] ( src/119.c ) |
79
79
| 118 | [ Pascal's Triangle] | [ C] ( src/118.cpp ) |
80
80
| 117 | [ Populating Next Right Pointers in Each Node II] | |
81
81
| 116 | [ Populating Next Right Pointers in Each Node] | |
@@ -224,7 +224,7 @@ them with C++ Language.
224
224
[ Intersection of Two Linked Lists ] : https://leetcode.com/problems/intersection-of-two-linked-lists/
225
225
[ Longest Substring with At Most Two Distinct Characters ] : https://leetcode.com/problems/longest-substring-with-at-most-two-distinct-characters/
226
226
[ Read N Characters Given Read4 II - Call multiple times ] : https://leetcode.com/problems/read-n-characters-given-read4-ii-call-multiple-times/
227
- [ Read N Characters Given Read4 ] : https://leetcode.com/problems/read4 -n-characters-given-read /
227
+ [ Read N Characters Given Read4 ] : https://leetcode.com/problems/read -n-characters-given-read4 /
228
228
[ Binary Tree Upside Down ] : https://leetcode.com/problems/binary-tree-upside-down/
229
229
[ Min Stack ] : https://leetcode.com/problems/min-stack/
230
230
[ Find Minimum in Rotated Sorted Array II ] : https://leetcode.com/problems/find-minimum-in-rotated-sorted-array-ii/
Original file line number Diff line number Diff line change
1
+ #include <stdio.h>
2
+ #include <stdlib.h>
3
+
4
+ int * getRow (int rowIndex ) {
5
+ int k = rowIndex ;
6
+ int * ans = (int * )calloc (k + 1 , sizeof (int ));
7
+ int i , j ;
8
+ int prev = 0 , cur = 0 ;
9
+ ans [0 ] = 1 ;
10
+ for (i = 1 ; i < k + 1 ; i ++ ) {
11
+ prev = ans [0 ];
12
+ for (j = 1 ; j < i ; j ++ ) {
13
+ cur = ans [j ];
14
+ ans [j ] += prev ;
15
+ prev = cur ;
16
+ }
17
+ ans [i ] = 1 ;
18
+ }
19
+ return ans ;
20
+ }
21
+
22
+ int main () {
23
+ int k = 5 ;
24
+ int * ans = getRow (k );
25
+ int i ;
26
+ for (i = 0 ; i < k + 1 ; i ++ ) {
27
+ printf ("%d " , ans [i ]);
28
+ }
29
+ printf ("\n" );
30
+ return 0 ;
31
+ }
You can’t perform that action at this time.
0 commit comments