add: 231016

This commit is contained in:
Eatswap 2023-10-16 23:30:34 +08:00
parent c920f9bfd4
commit db721a1db1
Signed by: Eatswap
GPG Key ID: BE661106A1F3FA0B
2 changed files with 22 additions and 0 deletions

17
cpp/2308/LC231016.cpp Normal file
View File

@ -0,0 +1,17 @@
#include "defs.h"
class LC231016 {
public:
static std::vector<int> getRow(int rowIndex) noexcept;
};
std::vector<int> LC231016::getRow(int rowIndex) noexcept {
int row[36] {1};
int tmp[36] {1};
for (int i = 0; i < rowIndex; ++i) {
for (int j = 1; j < 35; ++j)
tmp[j] = row[j] + row[j - 1];
std::memcpy(row + 1, tmp + 1, 35 * sizeof(int));
}
return {row, row + rowIndex + 1};
}

View File

@ -41,4 +41,9 @@ public:
static int numWays(int, int); static int numWays(int, int);
}; };
class LC231016 {
public:
static std::vector<int> getRow(int rowIndex) noexcept;
};
#endif //LEETCODE_CPP_DEFS_H #endif //LEETCODE_CPP_DEFS_H