분류 전체보기148 [Swift] LeetCode - 1038. Binary Search Tree to Greater Sum Tree 문제: https://leetcode.com/problems/binary-search-tree-to-greater-sum-tree/ Binary Search Tree to Greater Sum Tree - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 오른쪽 -> 가운데 -> 왼쪽 순서로 돌면 됩니다! class Solution { var value = 0 func bstToGst(_ root: TreeNode?) -> TreeNode? { if root != .. 2022. 2. 17. [Swift] LeetCode - 297. Serialize and Deserialize Binary Tree 문제: https://leetcode.com/problems/serialize-and-deserialize-binary-tree/ Serialize and Deserialize Binary Tree - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com null이면 #을 넣어 직렬화하였습니다. class Codec { func serialize(_ root: TreeNode?) -> String { var queue = [root] var result = [Strin.. 2022. 2. 17. [Swift] LeetCode - 207. Course Schedule 문제: https://leetcode.com/problems/course-schedule/ Course Schedule - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 위상정렬로 풀었습니다. import Foundation class Solution { func canFinish(_ numCourses: Int, _ prerequisites: [[Int]]) -> Bool { var degrees = Array(repeating: 0, count: numCou.. 2022. 2. 16. [Swift] LeetCode - 78. Subsets 문제: https://leetcode.com/problems/subsets/ Subsets - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com import Foundation class Solution { func subsets(_ nums: [Int]) -> [[Int]] { var result = [[Int]]() func combination(_ index: Int, _ nowCombi: [Int]) { result.append(nowCombi) if now.. 2022. 2. 16. [Swift] LeetCode - 39. Combination Sum 문제: https://leetcode.com/problems/combination-sum/ Combination Sum - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 조합을 응용해서 했습니다. import Foundation class Solution { func combinationSum(_ candidates: [Int], _ target: Int) -> [[Int]] { var result = [[Int]]() func combination(_ inde.. 2022. 2. 16. [Swift] LeetCode - 17. Letter Combinations of a Phone Number 문제: https://leetcode.com/problems/letter-combinations-of-a-phone-number/ Letter Combinations of a Phone Number - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 조합 문제입니다. import Foundation class Solution { func letterCombinations(_ digits: String) -> [String] { if digits.isEmpty { .. 2022. 2. 16. 이전 1 ··· 7 8 9 10 11 12 13 ··· 25 다음