Shawn's Blog

  • Home
  • Tags
  • Categories
  • Archives
  • Search
  • Table of Contents
  • Overview

Shawn

若有恒,何必三更眠五更起;最无益,莫过一日曝十日寒。
392 posts
13 categories
114 tags

LeetCode 119. Pascal's Triangle II

Posted on 2021-02-12 Edited on 2024-11-24 In LeetCode
1
2
3
4
5
6
7
8
9
10
class Solution {
public:
vector<int> getRow(int rowIndex) {
vector<int> row(rowIndex + 1);
row[0] = 1;
for (int i = 1; i <= rowIndex; ++i)
row[i] = 1LL * row[i - 1] * (rowIndex - i + 1) / i;
return row;
}
};
# Array
LeetCode 703. Kth Largest Element in a Stream
LeetCode 118. Pascal's Triangle
© 2024 Shawn
Powered by Hexo & NexT.Mist
0%