
문제 설명
Given an integer rowIndex, return the (0-indexed) row of the Pascal's triangle.
In Pascal's triangle, each number is the sum of the two numbers directly above it as shown:

제한 조건
입출력 예
Example 1
Input: numRows = 3
Output: [1,3,3,1]
Example 2
Input: numRows = 0
Output: [1]
Example 3
Input: numRows = 1
Output: [1,1]
class Solution {
public List<List<Integer>> generate(int numRows) {
List<List<Integer>> result = new ArrayList<>();
for(int i=0; i<numRows; i++) {
List<Integer> list = new ArrayList<>();
for(int j=0; j<=i; j++) {
if(j == 0 || j == i) {
list.add(1);
} else {
int prev = result.get(i-1).get(j-1);
int next = result.get(i-1).get(j);
list.add(prev+next);
}
}
result.add(list);
}
return result.get(result.size()-1);
}
}
return 값만 변경해주었다.다른 방법으로도 접근해볼까? 했지만, return 만 변경해주었다.