题目链接:https://leetcode-cn.com/problems/same-tree/ 思路:同时深搜或广搜两棵树,比较值即可 class Solution { public boolean isSameTree(TreeNode p, TreeNode q) { //100 5 if(p ...
分类:
其他好文 时间:
2020-08-07 09:43:32
阅读次数:
51
给定一个整数数组 nums 和一个目标值 target,请你在该数组中找出和为目标值的那 两个 整数,并返回他们的数组下标。 你可以假设每种输入只会对应一个答案。但是,数组中同一个元素不能使用两遍。 给定 nums = [2, 7, 11, 15], target = 9 因为 nums[0] + ...
分类:
其他好文 时间:
2020-08-06 19:31:23
阅读次数:
67
写在前面,参考的是力扣官网的画解算法 一、java代码 /* * @lc app=leetcode.cn id=7 lang=java * * [7] 整数反转 */ // @lc code=start class Solution { public int reverse(int x) { //定 ...
分类:
其他好文 时间:
2020-08-06 17:09:42
阅读次数:
66
给定一个包含 0 和 1 的二维网格地图,其中 1 表示陆地 0 表示水域。 网格中的格子水平和垂直方向相连(对角线方向不相连)。整个网格被水完全包围,但其中恰好有一个岛屿(或者说,一个或多个表示陆地的格子相连组成的岛屿)。 岛屿中没有“湖”(“湖” 指水域在岛屿内部且不和岛屿周围的水相连)。格子是 ...
分类:
其他好文 时间:
2020-08-06 17:00:45
阅读次数:
62
Leetcode.345 Reverse Vowels of a String Write a function that takes a string as input and reverse only the vowels of a string. Example 1: Input: "hell ...
分类:
其他好文 时间:
2020-08-06 09:30:08
阅读次数:
64
https://leetcode-cn.com/problems/house-robber-iii/solution/da-jia-jie-she-iii-by-leetcode-solution/ class Solution { public: unordered_map <TreeNode*, ...
分类:
其他好文 时间:
2020-08-05 23:24:01
阅读次数:
97
链接:https://leetcode-cn.com/problems/word-break/ 代码 /* * @lc app=leetcode.cn id=139 lang=cpp * * [139] 单词拆分 */ // @lc code=start class Solution { publi ...
分类:
其他好文 时间:
2020-08-03 23:33:50
阅读次数:
84