We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 75500d6 commit 9266a00Copy full SHA for 9266a00
Dynamic Programming/Pascals Triangle ||.cpp
@@ -0,0 +1,34 @@
1
+class Solution
2
+{
3
+public:
4
+ vector<int> getRow(int rowIndex)
5
+ {
6
+ int numRows = rowIndex + 1;
7
+ vector<vector<int> > res;
8
+ vector<int> temp;
9
+ temp.push_back(1);
10
+ res.push_back(temp);
11
+ if (numRows == 1)
12
13
+ return temp;
14
+ }
15
16
17
+ int count = 2;
18
+ while (count < numRows)
19
20
+ int n = res.size();
21
+ int j = res[n - 1].size();
22
23
24
+ for (int i = 0; i < j - 1; i++)
25
26
+ temp.push_back(res[n - 1][i] + res[n - 1][i + 1]);
27
28
29
30
+ count++;
31
32
+ return res[numRows - 1];
33
34
+};
0 commit comments