100.same-tree

本文探讨了如何通过编写函数来判断两个二叉树是否在结构上相同且节点值一致。给出了具体的示例并详细解释了解题思路。

给定两个二叉树,写一个函数来检查它们是否相同。

如果两棵树在结构上相同并且节点具有相同的值,则认为它们是相同的。

 

示例 1:

输入 :     1          1
          / \       / \
         2   3     2   3

        [1,2,3],   [1,2,3]

输出: true

示例 2:

输入  :    1          1
          /           \
         2             2

        [1,2],     [1,null,2]

输出: false

例 3:

输入 :     1          1
          / \       / \
         2   1     1   2

        [1,2,1],   [1,1,2]

输出: false

解题思路:

    先判断这两个点是不是为空,然后通过函数迭代来判读,他们的值、左节点、右节点是否相等。

$ git lfs install --global Error: unknown flag: --global git lfs install [options] Perform the following actions to ensure that Git LFS is setup properly: * Set up the clean and smudge filters under the name "lfs" in the global Git config. * Install a pre-push hook to run git lfs pre-push for the current repository, if run from inside one. If "core.hooksPath" is configured in any Git configuration (and supported, i.e., the installed Git version is at least 2.9.0), then the pre-push hook will be installed to that directory instead. Options: Without any options, git lfs install will only setup the "lfs" smudge and clean filters if they are not already set. --force: Sets the "lfs" smudge and clean filters, overwriting existing values. --local: Sets the "lfs" smudge and clean filters in the local repository's git config, instead of the global git config (~/.gitconfig). --worktree: Sets the "lfs" smudge and clean filters in the current working tree's git config, instead of the global git config (~/.gitconfig) or local repository's git config ($GIT_DIR/config). If multiple working trees are in use, the Git config extension worktreeConfig must be enabled to use this option. If only one working tree is in use, --worktree has the same effect as --local. This option is only available if the installed Git version is at least 2.20.0 and therefore supports the "worktreeConfig" extension. --manual: Print instructions for manually updating your hooks to include git-lfs functionality. Use this option if git lfs install fails because of existing hooks and you want to retain their functionality. --system: Sets the "lfs" smudge and clean filters in the system git config, e.g. /etc/gitconfig instead of the global git config (~/.gitconfig). --skip-smudge: Skips automatic downloading of objects on clone or pull. This requires a manual "git lfs pull" every time a new commit is checked out on your repository. --skip-repo: Skips installation of hooks into the local repository; use if you want to install the LFS filters but not make changes to the hooks. It is valid to use --local, --global, or --system in conjunction with this option.
最新发布
07-03
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值