[Swift 알고리즘] LeetCode 119. Pascal's Triangle II ○ Dynamic Programming | Easy 119. Pascal's Triangle II class Solution { func getRow(_ rowIndex: Int) -> [Int] { var row = [1] if rowIndex == 0 { return row } for i in 1...rowIndex { var newRow = Array(repeating: 1, count: i + 1) for j in 1.. Algorithm/LeetCode 2023.04.01
[Swift 알고리즘] LeetCode 118. Pascal's Triangle ○ Dynamic Programming | Easy 118. Pascal's Triangle 제출 답안 30분 append([1]) 해주고 더한 값들 append 해주고 마지막에 append 1 해주는 방법 class Solution { func generate(_ numRows: Int) -> [[Int]] { var result = [[1]] for i in 1.. Algorithm/LeetCode 2023.04.01
[Swift 알고리즘] LeetCode 2457. Minimum Addition to Make Integer Beautiful × 그리디? Medium You are given two positive integers n and target. An integer is considered beautiful if the sum of its digits is less than or equal to target. Return the minimum non-negative integer x such that n + x is beautiful. The input will be generated such that it is always possible to make n beautiful. Constraints: - 1 Int { var array = String(n).map({ Int(String($0))! }) var sum = array.r.. Algorithm/LeetCode 2023.03.10