-
[LeetCode] Pascal's Triangle알고리즘 2019. 12. 4. 17:03
문제
Given a non-negative integer numRows, generate the first numRows of Pascal's triangle.
In Pascal's triangle, each number is the sum of the two numbers directly above it.Example:
Input: 5 Output: [ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1] ]
Approach
이전 줄의 원소를 더해 다음 줄을 만들면 된다
굳이 따지자면 DP?
Code
https://github.com/chi3236/algorithm/blob/master/LeetCode_Pascal'sTriangle.cpp
'알고리즘' 카테고리의 다른 글
[LeetCode] Best Time to Buy and Sell Stock II (0) 2019.12.04 [LeetCode] Best Time to Buy and Sell Stock (0) 2019.12.04 [LeetCode] Populating Next Right Pointers in Each Node (0) 2019.12.04 [LeetCode] Convert Sorted Array to Binary Search Tree (0) 2019.12.04 [LeetCode] Construct Binary Tree from Preorder and Inorder Traversal (0) 2019.12.04