问题: Given two binary trees, write a function to check if they are equal or not. Two binary trees are considered equal if they are structurally identical and the nodes have the same value. 分析: 考虑使用深度优先遍历的方法,同时遍历两棵树,遇到不等的就返回. 代码如下: /** * Definition f…
小希的迷宫 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 27851 Accepted Submission(s): 8613 Problem Description 上次Gardon的迷宫城堡小希玩了很久(见Problem B),现在她也想设计一个迷宫让Gardon来走.但是她设计迷宫的思路不一样,首先她认为所有的通道都应该是双…
题目:Symmetric Tree <span style="font-size:18px;"><span style="font-size:18px;">/**LeetCode Symmetric Tree 对称的树 * 思路:推断一棵树是否对称,1.有左子树就要有右子树 * 2.除根节点外对称节点值要同样 * 注意:对称后就是左子树的左节点和右子树的右节点比較 * Definition for binary tree * public c…
A Simple Problem with Integers Time Limit: 5000/1500 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 5034 Accepted Submission(s): 1589 Problem Description Let A1, A2, ... , AN be N elements. You need to deal with…