[LeetCode 풀이/python] 113. Path Sum II (medium)
문제 설명: 이진트리 root 와 정수 targetSum 이 주어졌을 때, 루트에서 단말 노드까지의 경로에 있는 모든 수의 합이 targetSum 과 같아지는 경로를 모두 리턴하시오. 단말 노드는 자식 노드를 갖지 않는 노드를 가리킴. (Given the root of a binary tree and an integer targetSum, return all root-to-leaf paths where each path's sum equals targetSum. A leaf is a node with no children.) 예시 1) 입력: root = [5,4,8,11,null,13,4,7,2,null,null,5,1], targetSum = 22 --> 출력: [[5,4,11,2],[5,8,4,5]..
2021. 3. 10.
[LeetCode 풀이/python] 47. Permutations II (medium)
문제 설명: 중복을 허용하는 숫자들의 집합 nums 가 주어졌을 때, 이를 통해 만들 수 있는 모든 고유한 순열(permutations) 조합을 리턴하시오. 리스트 내 조합의 순서는 무관하다. (Given a collection of numbers, nums, that might contain duplicates, return all possible unique permutations in any order.) 예시 1) 입력: nums = [1,1,2] --> 출력: [[1,1,2], [1,2,1], [2,1,1]] 예시 2) 입력: nums = [1,2,3] --> 출력: [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]] 제한 조건: 1
2021. 2. 16.