Skip to content

Instantly share code, notes, and snippets.

@Maggie199
Created January 17, 2015 02:22
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 Maggie199/5aa6bbc5e550ffa8380b to your computer and use it in GitHub Desktop.
Save Maggie199/5aa6bbc5e550ffa8380b to your computer and use it in GitHub Desktop.
Leetcode #119
public List<Integer> getRow(int rowIndex) {
List<Integer> result = new ArrayList<Integer>();
for(int i=0; i<=rowIndex; i++){
if(i == 0 )
result.add(1);
else{
List<Integer> temp = new ArrayList<Integer>(result);
for(int j=1;j<i;j++){
result.set(j, temp.get(j-1) + temp.get(j));
}
result.add(1);
}
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment