题目链接:https://leetcode-cn.com/problems/flip-equivalent-binary-trees/ 解题思路:进行递归,当root1和root2都为空时,返回true,如果双方一个不为空,另一个为空为或双方根节点值不相等false,否则对左右子树分别不翻转判断或翻 ...
分类:
其他好文 时间:
2020-07-18 21:54:16
阅读次数:
70
给定四个包含整数的数组列表 A , B , C , D ,计算有多少个元组 (i, j, k, l) ,使得 A[i] + B[j] + C[k] + D[l] = 0。 为了使问题简单化,所有的 A, B, C, D 具有相同的长度 N,且 0 ≤ N ≤ 500 。所有整数的范围在 -228 到 ...
分类:
其他好文 时间:
2020-07-18 15:37:40
阅读次数:
64
链接:https://leetcode-cn.com/problems/unique-binary-search-trees-ii/ 代码 /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNo ...
分类:
其他好文 时间:
2020-07-18 13:39:30
阅读次数:
56
链接:https://leetcode-cn.com/problems/binary-tree-inorder-traversal/ 代码 /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNo ...
分类:
其他好文 时间:
2020-07-18 11:34:31
阅读次数:
66
链接:https://leetcode-cn.com/problems/unique-binary-search-trees/ 代码 class Solution { public: int numTrees(int n) { vector<int> f(n + 1); f[0] = 1; for ...
分类:
其他好文 时间:
2020-07-18 11:25:21
阅读次数:
56
链接:https://leetcode-cn.com/problems/interleaving-string/ 代码 class Solution { public: bool isInterleave(string s1, string s2, string s3) { int n = s1.s ...
分类:
其他好文 时间:
2020-07-18 11:21:07
阅读次数:
43
力扣链接:https://leetcode-cn.com/problems/dui-lie-de-zui-da-zhi-lcof/ 题目描述 请定义一个队列并实现函数 max_value 得到队列里的最大值,要求函数max_value、push_back 和 pop_front 的均摊时间复杂度都是 ...
分类:
其他好文 时间:
2020-07-18 00:40:15
阅读次数:
67
1 给出一个 32 位的有符号整数,你需要将这个整数中每位上的数字进行反转。 2 3 示例 1: 4 5 输入: 123 6 输出: 321 7 示例 2: 8 9 输入: -123 10 输出: -321 11 示例 3: 12 13 输入: 120 14 输出: 21 15 注意: 16 17 ...
分类:
其他好文 时间:
2020-07-17 22:26:21
阅读次数:
74
package LeetCode_279 import java.util.* import kotlin.collections.HashSet /** * 279. Perfect Squares * https://leetcode.com/problems/perfect-squares/d ...
分类:
其他好文 时间:
2020-07-17 01:15:12
阅读次数:
72
题目链接:https://leetcode-cn.com/problems/n-ary-tree-postorder-traversal/ 方法一递归法:先访问子节点,然后访问根。LeetCode代码: /* // Definition for a Node. class Node { public ...
分类:
其他好文 时间:
2020-07-16 21:39:10
阅读次数:
79