From cf2a86785e3eaf9c7cd6eef1ac994119ab256754 Mon Sep 17 00:00:00 2001 From: Won Joon Thomas Choi <113500771+724thomas@users.noreply.github.com> Date: Tue, 8 Sep 2026 22:39:58 +0900 Subject: [PATCH 1/2] Create 1886. Determine Whether Matrix Can Be Obtained By Rotation.py --- ...her Matrix Can Be Obtained By Rotation.py" | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 "leetcode3/\354\265\234\354\233\220\354\244\200/1886. Determine Whether Matrix Can Be Obtained By Rotation.py" diff --git "a/leetcode3/\354\265\234\354\233\220\354\244\200/1886. Determine Whether Matrix Can Be Obtained By Rotation.py" "b/leetcode3/\354\265\234\354\233\220\354\244\200/1886. Determine Whether Matrix Can Be Obtained By Rotation.py" new file mode 100644 index 00000000..25792dd6 --- /dev/null +++ "b/leetcode3/\354\265\234\354\233\220\354\244\200/1886. Determine Whether Matrix Can Be Obtained By Rotation.py" @@ -0,0 +1,32 @@ +# + +''' +1. 아이디어 : +- + +2. 시간복잡도 : + O(n * m) + +3. 자료구조/알고리즘 : +- + +''' +class Solution: + def findRotation(self, mat: List[List[int]], target: List[List[int]]) -> bool: + n = len(mat) + m = len(mat[0]) + # 0, 90, 180, 270 + ans = [1, 1, 1, 1] + for row in range(n): + for col in range(m): + if mat[row][col] != target[row][col]: + ans[0] = 0 + if mat[row][col] != target[col][n-row-1]: + ans[1] = 0 + if mat[row][col] != target[n-row-1][m-col-1]: + ans[2] = 0 + if mat[row][col] != target[n-col-1][row]: + ans[3] = 0 + + return sum(ans) >= 1 + From ecbc84cc8c1b77864adaecbfc1c76e4f0edafded Mon Sep 17 00:00:00 2001 From: Won Joon Thomas Choi <113500771+724thomas@users.noreply.github.com> Date: Tue, 8 Sep 2026 22:42:28 +0900 Subject: [PATCH 2/2] Create 894. All Possible Full Binary Trees.py --- .../894. All Possible Full Binary Trees.py" | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 "leetcode3/\354\265\234\354\233\220\354\244\200/894. All Possible Full Binary Trees.py" diff --git "a/leetcode3/\354\265\234\354\233\220\354\244\200/894. All Possible Full Binary Trees.py" "b/leetcode3/\354\265\234\354\233\220\354\244\200/894. All Possible Full Binary Trees.py" new file mode 100644 index 00000000..ebba3832 --- /dev/null +++ "b/leetcode3/\354\265\234\354\233\220\354\244\200/894. All Possible Full Binary Trees.py" @@ -0,0 +1,57 @@ +# + +''' +1. 아이디어 : +backtracking으로 왼쪽과 오른쪽 브랜치에 각각 몇개의 노드가 들어갈지 매번 계산한다. + +2. 시간복잡도 : + O(2^n) + +3. 자료구조/알고리즘 : +backtracking + +''' +# Definition for a binary tree node. +# class TreeNode: +# def __init__(self, val=0, left=None, right=None): +# self.val = val +# self.left = left +# self.right = right +class Solution: + def allPossibleFBT(self, n: int) -> List[Optional[TreeNode]]: + + # def copy_tree(original_node): + # if not original_node: + # return + + # copied = TreeNode(0) + # copied.left = copy_tree(original_node.left) + # copied.right = copy_tree(original_node.right) + + # return copied + + + def backtrack(nodes): + + if nodes == 1: + return [TreeNode(0)] + + trees = [] + for left_count in range(1, nodes-1, 2): + right_count = nodes - 1 - left_count + + left_trees = backtrack(left_count) + right_trees = backtrack(right_count) + + for left_tree in left_trees: + for right_tree in right_trees: + root = TreeNode(0) + root.left = left_tree + root.right = right_tree + + trees.append(root) + return trees + + return backtrack(n) + +