File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change 18
18
2 . [ Rotting Oranges] ( https://leetcode.com/explore/challenge/card/august-leetcoding-challenge/550/week-2-august-8th-august-14th/3418/ ) ➡️ [ CPP Solution] ( Week2/orangesRotting.cpp )
19
19
3 . [ Excel Sheet Column Number] ( https://leetcode.com/explore/challenge/card/august-leetcoding-challenge/550/week-2-august-8th-august-14th/3419/ ) ➡️ [ CPP Solution] ( Week2/titleToNumber.cpp )
20
20
4 . [ H Index] ( https://leetcode.com/explore/challenge/card/august-leetcoding-challenge/550/week-2-august-8th-august-14th/3420/ ) ➡️ [ CPP Solution] ( Week2/hIndex.cpp )
21
+ 5 . [ Pascal's Triangle II] ( https://leetcode.com/explore/challenge/card/august-leetcoding-challenge/550/week-2-august-8th-august-14th/3421/ ) ➡️ [ CPP Solution] ( Week2/pascalTriangle2.cpp )
21
22
22
23
## Where to find me? 🌟
23
24
* [ Website] ( https://akashwho.codes/ )
Original file line number Diff line number Diff line change
1
+ class Solution {
2
+ public:
3
+ vector<int > getRow (int k) {
4
+ vector<int > prev;
5
+ prev.push_back (1 );
6
+
7
+ vector<int > res (prev);
8
+
9
+ for (int i = 1 ; i <= k; ++i) {
10
+ res.clear ();
11
+ res.push_back (1 );
12
+
13
+ for (int p = 0 ; p < prev.size () - 1 ; ++p) {
14
+ res.push_back (prev.at (p) + prev.at (p + 1 ));
15
+ }
16
+
17
+ res.push_back (1 );
18
+
19
+ prev = res;
20
+ }
21
+
22
+ return res;
23
+ }
24
+ };
You can’t perform that action at this time.
0 commit comments