1
0
Fork 0
mirror of https://gitlab.com/mfocko/LeetCode.git synced 2024-09-19 17:56:55 +02:00
LeetCode/cpp/pascals-triangle-ii.cpp
Matej Focko b229608723
cpp(chore): add clang-format style and format
Signed-off-by: Matej Focko <me@mfocko.xyz>
2024-01-03 12:06:54 +01:00

15 lines
393 B
C++

class Solution {
public:
vector<int> getRow(int rowIndex) {
vector<int> result;
result.push_back(1);
for (auto k = 0; k < rowIndex; k++) {
auto next = static_cast<int>(static_cast<long>(result.back()) *
(rowIndex - k) / (k + 1));
result.push_back(next);
}
return result;
}
};