전체 글
-
[LeetCode] [DP] 118. Pascal's TriangleAlgorithm/LeetCode 2021. 10. 25. 13:09
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]] class Solution: def generate(self, numRows: int) -> List[List[int]]: if numRows == 1: ..
-
[LeetCode] [DP] 70. Climbing Stairs카테고리 없음 2021. 10. 8. 10:57
You are climbing a staircase. It takes n steps to reach the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? Example 1: Input: n = 2 Output: 2 Explanation: There are two ways to climb to the top. 1. 1 step + 1 step 2. 2 steps Example 2: Input: n = 3 Output: 3 Explanation: There are three ways to climb to the top. 1. 1 step + 1 step + 1 step 2...