- Today
- Total
목록전체 글 (384)
작심삼일
문제 링크: https://leetcode.com/problems/pseudo-palindromic-paths-in-a-binary-tree/ 문제 Given a binary tree where node values are digits from 1 to 9. A path in the binary tree is said to be pseudo-palindromic if at least one permutation of the node values in the path is a palindrome. Return the number of pseudo-palindromic paths going from the root node to leaf nodes. 조건 The number of nodes in the tr..
문제 링크: https://leetcode.com/problems/binary-tree-inorder-traversal/ 문제 Given the root of a binary tree, return the inorder traversal of its nodes' values. 조건 The number of nodes in the tree is in the range [0, 100]. -100
문제 링크: https://leetcode.com/problems/construct-string-from-binary-tree/ 문제 Given the root of a binary tree, construct a string consisting of parenthesis and integers from a binary tree with the preorder traversal way, and return it. Omit all the empty parenthesis pairs that do not affect the one-to-one mapping relationship between the string and the original binary tree. 조건 The number of nodes i..
문제 링크: https://leetcode.com/problems/binary-tree-pruning/ 문제 Given the root of a binary tree, return the same tree where every subtree (of the given tree) not containing a 1 has been removed. A subtree of a node node is node plus every node that is a descendant of node. 조건 The number of nodes in the tree is in the range [1, 200]. Node.val is either 0 or 1. 내 풀이 Tree 구조 관련 문제는 recursive하게 짠다. dfs..
문제 링크: https://leetcode.com/problems/n-ary-tree-level-order-traversal/ 문제 Given an n-ary tree, return the level order traversal of its nodes' values. Nary-Tree input serialization is represented in their level order traversal, each group of children is separated by the null value (See examples). 조건 The height of the n-ary tree is less than or equal to 1000 The total number of nodes is between [0..
문제 링크: https://leetcode.com/problems/average-of-levels-in-binary-tree/ 문제 Given the root of a binary tree, return the average value of the nodes on each level in the form of an array. Answers within $10^{-5}$ of the actual answer will be accepted. 조건 The number of nodes in the tree is in the range [1, $10^4$]. $-2^{31}$
문제 링크: https://leetcode.com/problems/count-good-nodes-in-binary-tree/ 문제 Given a binary tree root, a node X in the tree is named good if in the path from root to X there are no nodes with a value greater than X. Return the number of good nodes in the binary tree. 조건 The number of nodes in the binary tree is in the range [1, 10^5]. Each node's value is between [-10^4, 10^4]. 내 풀이 Tree 구조는 항상 recu..
문제 링크: https://leetcode.com/problems/pacific-atlantic-water-flow/ 문제 There is an m x n rectangular island that borders both the Pacific Ocean and Atlantic Ocean. The Pacific Ocean touches the island's left and top edges, and the Atlantic Ocean touches the island's right and bottom edges. The island is partitioned into a grid of square cells. You are given an m x n integer matrix heights where he..