LeetCode 118
-
[LeetCode/Java] 118. Pascal's Triangle - A0022022_PPS/2주차 2023. 1. 6. 02:42
- 문제 Given an integer numRows, return the first numRows of Pascal's triangle. In Pascal's triangle, each number is the sum of the two numbers directly above it as shown: - 알고리즘 return 형식에 맞게 list라는 배열을 생성하여 0번째와 마지막은 무조건 1을 넣고 아니라면 그 전 배열의 수를 더해서 넣도록 했다. List 의 형식을 처음 사용해봐서 조금 해맸던 것 같다. 난 항상 ArrayList[] 안에 ArrayList를 넣었기에 조금 힘들었던 것 같다. - 코드 class Solution { public List generate(int numRows) { Li..