전체 글

전체 글

    575 Distribute Candies

    575 Distribute Candies

    1. Description Alice has n candies, where ith candy is of type candyType[i]. Alice noticed that she started to gain weight, so she visited a doctor. The doctor advised Alice to only eat n / 2 of the candies she has (n is always even). Alice likes her candies very much, and she wants to each to eat maximum number of different types of candies whilte still following the doctor's advice. Given the ..

    572 Subtree of Another Tree

    572 Subtree of Another Tree

    1. Description Given the roots of two binary trees root and subRoot, return true if there is a subtree of root with the same structure and node values of subRoot and false otherwise. A subtree of a binary tree tree is a tree that consists of a node in tree and all of this node's descendants. The tree tree could also be considered as a subtree of itself. constraints : The number of nodes in the r..

    566 Reshape Matrix

    566 Reshape Matrix

    1. Description In MATLAB, there is a handy function called reshape which can reshape an $m \times n$ matrix into a new one with a different size $r \times c$ keeping its original data. You are given an $m \times n$ matrix mat and two integers r and c representing the number of rows and the number of columns of the wanted reshaped matrix. The reshaped matrix should be filled with all the elements..

    563 Binary Tree Tilt

    563 Binary Tree Tilt

    1. Description Given the root of a binary tree, return the sum of every tree node's tilt. The tilt of a tree node is the absolute difference between sum of all left subtree values and all right subtree node values. If a node does not have a left child then the sum of the left subtree node values is treated as 0. The rule is similar if the node doe not have a right child. constraints : The number..