[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] #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.