Skip to content

Instantly share code, notes, and snippets.

@codinfox
Created January 16, 2015 06:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codinfox/3769041c1bea449bd34d to your computer and use it in GitHub Desktop.
Save codinfox/3769041c1bea449bd34d to your computer and use it in GitHub Desktop.
class Solution {
public:
vector<int> getRow(int rowIndex) {
if (rowIndex < 0) return vector<int>();
vector<int> result{1};
while (rowIndex-- > 0) {
vector<int> tmp{1};
for (auto start = result.begin() + 1; start != result.end(); start++) {
tmp.push_back(*(start-1) + *start);
}
tmp.push_back(1);
result = tmp;
}
return result;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment