Created
January 16, 2015 06:43
-
-
Save codinfox/3769041c1bea449bd34d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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