본문 바로가기
반응형

LeetCode4

[LeetCode] 3Sum Closest 📄 [LeetCode] 3Sum Closest Given an array nums of n integers and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of the three integers. You may assume that each input would have exactly one solution. class Solution { func threeSumClosest(_ nums: [Int], _ target: Int) -> Int { var result: (Int, Int) = (Int.max, Int.zero) let sortedNums: Array =.. 2021. 3. 23.
[LeetCode] 3Sum 📄 [LeetCode] 3Sum Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero. Notice that the solution set must not contain duplicate triplets. func threeSum(_ nums: [Int]) -> [[Int]] { let testcase = nums.sorted() var result: [Int: Array] = [:] // Notice that the solution set must not contain d.. 2021. 3. 23.
[LeetCode] Valid Parentheses 📄 Vaild parentheses for Swift Source Code class Solution { func isValid(_ s: String) -> Bool { let confirm: [Character: Character] = ["(": ")", "{": "}", "[": "]"] var result: [Character] = [] for letter in s { if confirm.keys.contains(letter) { result.append(letter) continue } if let lastValue = result.last, let pair = confirm[lastValue], letter == pair { result.removeLast() continue } result.a.. 2021. 3. 21.
[TECH] 🔗 알고리즘 트레이닝 사이트 (Algorithm Training URL) 🔗알고리즘 트레이닝 사이트 (Algorithm Training URL) ➕ 001. 백준 알고리즘 (Baekjoon Online Judge) → https://www.acmicpc.net Baekjoon Online Judge Baekjoon Online Judge 프로그래밍 문제를 풀고 온라인으로 채점받을 수 있는 곳입니다. www.acmicpc.net ➕ 002. LeetCode → https://leetcode.com 力扣(LeetCode)官网 - 全球极客挚爱的技术成长平台 备战技术面试?力扣提供海量技术面试资源,帮助你高效提升编程技能,轻松拿下世界 IT 名企 Dream Offer。 leetcode.com ➕ 003. Samsung SW Expert Academy → https://swexpertacadem.. 2019. 12. 25.
반응형