当前位置 : 主页 > 手机开发 > harmonyos >

leetcode-865-Smallest Subtree with all the Deepest Nodes

来源:互联网 收集:自由互联 发布时间:2023-08-26
With pattern: if(node == NULL){ // do something}left = do_something(root-left)right = do_something(root-right)do_something with root, left, right we can get that, left and right return its depth and the deepest node’s parents Error: do no


With pattern:

if(node == NULL){
 // do something
}
left = do_something(root->left)
right = do_something(root->right)
do_something with root, left, right

we can get that, left and right return its depth and the deepest node’s parents

Error:

  1. do not know the meaning of function and its return, with function depth(root), we return current depth of subtree, and the deepest node in the pair structure.


网友评论