본문 바로가기
반응형

#알고리즘 [Algorithm]47

[LeetCode] Combination Sum 카테고리 (Category) 작성 날짜 (Write Date) 최근 수정 날자 (Recent Write Date) 작성자 (Writer) Algorithm 2020.04.21. 21:49:52 2020.04.21. 21:49:52 Dev.Yang [문제내용] Given an array of distinct integers candidates and a target integer target, return a list of all unique combinations of candidates where the chosen numbers sum to target. You may return the combinations in any order. The same number may be chosen from c.. 2021. 4. 21.
[프로그래머스 - 탐욕법] 체육복 카테고리 (Category) 작성 날짜 (Write Date) 최근 수정 날자 (Recent Write Date) 작성자 (Writer) Algorithm 2020.04.03. 19:55:27 2020.04.03. 19:55:27 Dev.Yang 점심시간에 도둑이 들어, 일부 학생이 체육복을 도난당했습니다. 다행히 여벌 체육복이 있는 학생이 이들에게 체육복을 빌려주려 합니다. 학생들의 번호는 체격 순으로 매겨져 있어, 바로 앞번호의 학생이나 바로 뒷번호의 학생에게만 체육복을 빌려줄 수 있습니다. 예를 들어, 4번 학생은 3번 학생이나 5번 학생에게만 체육복을 빌려줄 수 있습니다. 체육복이 없으면 수업을 들을 수 없기 때문에 체육복을 적절히 빌려 최대한 많은 학생이 체육수업을 들어야 합니다. 전체 학생의 .. 2021. 4. 3.
[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.
반응형