250x250
반응형
Notice
Recent Posts
Recent Comments
Link
목록파스칼 (2)
N

118. Pascal's Triangle 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: Example 1: Input: numRows = 5 Output: [[1],[1,1],[1,2,1],[1,3,3,1],[1,4,6,4,1]] Example 2: Input: numRows = 1 Output: [[1]] Constraints: 1
Leet Code 알고리즘
2021. 7. 15. 14:50
(SWEA c++)2005. 파스칼의 삼각형
swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV5P0-h6Ak4DFAUq&categoryId=AV5P0-h6Ak4DFAUq&categoryType=CODE SW Expert Academy SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요! swexpertacademy.com 2차원 배열을 이용하여 수를 채워나가도록 한다. 최대가 10이므로 arr[10][10]을 선언. arr[0][0]은 1을 넣어주어 시작. 파스칼의 삼각형을 10단계가지 채워둔 후 원하는 단계만큼 출력해주면 시간을 줄일 수 있다. 이중 for문을 이용. i = 단계, j = 각 단계에서의 위치를 나타낸다. 만약 j == 0 또는 j ..
SW Expert Academy
2020. 9. 28. 15:09