💯 Daily LeetCode Challenge Day_13 - Same Tree
문제 Given two binary trees, write a function to check if they are the same or not. Two binary trees are considered the same if they are structurally identical and the nodes have the same value. Example 1: Input: 1 1 / \ / \ 2 3 2 3 [1,2,3], [1,2,3] Output: true Example 2: Input: 1 1 / \ 2 2 [1,2], [1,null,2] Output: false Example 3: Input: 1 1 / \ / \ 2 1 1 2 [1,2,1], [1,1,2] Output: false dfs로 t..
2020. 7. 13.
Swift - 순열(Permutation)
1,2,3,4,5,6,7,8,9 중에서 중복되지 않고 3개를 뽑는 모든 경우의 수를 만들어라 예를들어 [1,2,3] [1,2,4] ... [9,8,7] 코드 import Foundation func permutation(_ arr : [Int],_ output : [Int],_ visited : [Bool],_ depth : Int,_ n : Int,_ r : Int){ var arr = arr var output = output var visited = visited if depth == r { // stack.append(output) print(output) return } for i in 0..
2020. 7. 11.