전체 글 422

[Binary Search Tree][Medium] 450. Delete Node in a BST

https://leetcode.com/problems/delete-node-in-a-bst/description Q. 주어진 BST에서 특정 값인 노드를 삭제하라. Solution. 2진트리 삭제 연산 코딩을 확인하는 문제이다. 2진 트리의 특성을 유지하면서 특정 노드를 삭제하라면, 대상 노드를 삭제하고 어떤 노드를 삭제된 노드의 자리에 위치케 할지를 결정하는지가 알고리즘의 핵심이라 하겠다. 연산 자체는 이런 식이다. 2진 트리에서, 특정 노드를 제거하면, > 노드의 좌측 사이드에서 제일 큰 값을 가진 노드, 혹은 > 우측 사이드에서 가장 작은 값을 가진 노드 를 해당 삭제된 노드 자리에 위치하면 해당 트리의 특성이 유지된다. 따라서 해당 문제를 풀기 위해서는 > 특정 노드 탐색 > 특정 노드 기준, c..

Leetcode/LeetCode75 2023.12.31

[Binary Search Tree][Easy] 700. Search in a Binary Search Tree

https://leetcode.com/problems/search-in-a-binary-search-tree/description Search in a Binary Search Tree - LeetCode Can you solve this real interview question? Search in a Binary Search Tree - You are given the root of a binary search tree (BST) and an integer val. Find the node in the BST that the node's value equals val and return the subtree rooted with that node. If leetcode.com Q. 주어진 Binary..

Leetcode/LeetCode75 2023.12.30

[Binary Tree-BFS][Medium] 1161. Maximum Level Sum of a Binary Tree

https://leetcode.com/problems/maximum-level-sum-of-a-binary-tree/description Maximum Level Sum of a Binary Tree - LeetCode Can you solve this real interview question? Maximum Level Sum of a Binary Tree - Given the root of a binary tree, the level of its root is 1, the level of its children is 2, and so on. Return the smallest level x such that the sum of all the values of node leetcode.com Q. 주어..

Leetcode/LeetCode75 2023.12.28

[Binary Tree-BFS][Medium] 199. Binary Tree Right Side View

https://leetcode.com/problems/binary-tree-right-side-view/description Binary Tree Right Side View - LeetCode Can you solve this real interview question? Binary Tree Right Side View - Given the root of a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom. Example 1: [https://asse leetcode.com Q. 주어진 tree 에서 가장 우측 노..

Leetcode/LeetCode75 2023.12.28

[Binary Tree-DFS][Medium] 236. Lowest Common Ancestor of a Binary Tree

https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree/description Lowest Common Ancestor of a Binary Tree - LeetCode Can you solve this real interview question? Lowest Common Ancestor of a Binary Tree - Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. According to the definition of LCA on Wikipedia [https://en.wikipedia.org/wiki/ leetcode..

Leetcode/LeetCode75 2023.12.27

[Binary Tree-DFS][Medium] 1372. Longest ZigZag Path in a Binary Tree

https://leetcode.com/problems/longest-zigzag-path-in-a-binary-tree/description Longest ZigZag Path in a Binary Tree - LeetCode Can you solve this real interview question? Longest ZigZag Path in a Binary Tree - You are given the root of a binary tree. A ZigZag path for a binary tree is defined as follow: * Choose any node in the binary tree and a direction (right or left). * If the leetcode.com Q..

Leetcode/LeetCode75 2023.12.26

[Binary Tree-DFS][Medium] Path Sum III

https://leetcode.com/problems/path-sum-iii/description Path Sum III - LeetCode Can you solve this real interview question? Path Sum III - Given the root of a binary tree and an integer targetSum, return the number of paths where the sum of the values along the path equals targetSum. The path does not need to start or end at the roo leetcode.com Q. Tree 노드가 주어질때, 해당 노드의 leaf를 향하는 연속된 구간합이 targetS..

Leetcode/Challenges 2023.12.24

[Binary Tree][DFS] [Easy] 872. Leaf-Similar Trees

https://leetcode.com/problems/leaf-similar-trees/description Leaf-Similar Trees - LeetCode Can you solve this real interview question? Leaf-Similar Trees - Consider all the leaves of a binary tree, from left to right order, the values of those leaves form a leaf value sequence. [https://s3-lc-upload.s3.amazonaws.com/uploads/2018/07/16/tree.png leetcode.com Q. 두 노드가 주어질때, 해당 노드의 leaf node를 한쪽에서 읽..

Leetcode/LeetCode75 2023.12.21