
递归
biongbiongdou
这个作者很懒,什么都没留下…
展开
-
【LeetCode】Merge Two Binary Trees(C++)
Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not.You need to merge them into a new binary tree. ...原创 2018-05-05 22:06:51 · 262 阅读 · 0 评论 -
【LeetCode】104. Maximum Depth of Binary Tree(C++)
Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.Note: A leaf is a node with no children.Ex...原创 2018-05-07 21:24:19 · 161 阅读 · 0 评论 -
【LeetCode】226. Invert Binary Tree(C++)
Invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6 9to 4 / \ 7 2 / \ / \ 9 6 3 1这道题我是用递归求解的,代码如下:代码:(递归)/** * Definition for a binary tree node. * struct TreeN...原创 2018-05-07 22:02:01 · 209 阅读 · 0 评论 -
【HDU】1269 迷宫城堡(C++)
Problem Description为了训练小希的方向感,Gardon建立了一座大城堡,里面有N个房间(N<=10000)和M条通道(M<=100000),每个通道都是单向的,就是说若称某通道连通了A房间和B房间,只说明可以通过这个通道由A房间到达B房间,但并不说明通过它可以由B房间到达A房间。Gardon需要请你写个程序确认一下是否任意两个房间都是相互连通的,即:对于任意的i和j,...原创 2018-05-16 20:29:29 · 959 阅读 · 0 评论