본문 바로가기
반응형

Study/Algorithm38

[LeetCode] #78. Subsets (python) 문제 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 모든 부분집합을 반환해야 한다. 예시 입출력 Input: nums = [1,2,3] Output: [[],[1],[2],[1,2],[3],[1,3],[2,3],[1,2,3]] 풀이 내 풀이 class Solution: def subsets(self, nums: List[int]) -> List[List[int]]: outpu.. 2022. 3. 17.
[LeetCode] #39. Combination Sum (python) 문제 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 숫자 집합 candidates의 원소들을 조합해서 합한 값이 target이 되는 조합들을 반환해야 한다. 원소들은 중복 사용이 가능하다. 예시 입출력 Input: candidates = [2,3,6,7], target = 7 Output: [[2,2,3],[7]] 풀이 내 풀이 class Solu.. 2022. 3. 17.
[LeetCode] #77. Combinations (python) 문제 https://leetcode.com/problems/combinations/ Combinations - 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 주어진 정수 n, k를 가지고 [1, n] 범위로 가능한 k개의 조합을 반환해야 한다. 예시 입출력 Input: n = 4, k = 2 Output: [ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4], ] 풀이 책 풀이 1. dfs 활용 class Solution: def comb.. 2022. 3. 17.
[LeetCode] #46. Permutations (python) 문제 https://leetcode.com/problems/permutations/ Permutations - 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 받은 정수 배열로 가능한 모든 순열을 반환해야한다. 예시 입출력 Input: nums = [1,2,3] Output: [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]] 풀이 책 풀이 1. dfs 활용 class Solution: def permute(self, nums.. 2022. 3. 17.
반응형