给你一个链表,每 k 个节点一组进行翻转,请你返回翻转后的链表。 ...
分类:
其他好文 时间:
2020-06-21 17:48:12
阅读次数:
38
递归 思路: 代码: # Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = l ...
分类:
其他好文 时间:
2020-06-21 15:46:28
阅读次数:
40
题目 dfs求每一个节点向左走最大路径 + 节点值 + 向右走最大路径 搜索完后的最大值就是答案 dfs的出口和规则自己想有时候老想不通, 一看答案又一下子明白, 还是题目刷少了没经验 class Solution { public: int maxSum = 0xc0c0c0c0; // 全局变量 ...
分类:
其他好文 时间:
2020-06-21 15:36:34
阅读次数:
52
链接:https://leetcode-cn.com/problems/remove-duplicates-from-sorted-list/ 思路 因为输入的列表已排序,因此可以通过将当前结点的值与它之后的结点进行比较来确定它是否为重复结点。 如果它是重复的,更改当前结点的 next 指针,以便它 ...
分类:
编程语言 时间:
2020-06-21 14:15:24
阅读次数:
52
package LeetCode_934 import java.util.* /** * 934. Shortest Bridge * https://leetcode.com/problems/shortest-bridge/description/ * * In a given 2D bina ...
分类:
其他好文 时间:
2020-06-21 13:53:20
阅读次数:
56
public int[] pondSizes(int[][] land) { List<Integer> list = new ArrayList<>(); int temp; for (int i = 0; i < land.length; i++) { for (int j = 0; j < l ...
分类:
其他好文 时间:
2020-06-21 12:04:47
阅读次数:
127
题目描述 给你一个字符串 s 和一个字符规律 p,请你来实现一个支持 '.' 和 '*' 的正则表达式匹配。 '.' 匹配任意单个字符 '*' 匹配零个或多个前面的那一个元素 所谓匹配,是要涵盖 整个 字符串 s的,而不是部分字符串。 说明: s 可能为空,且只包含从 a-z 的小写字母。 p 可能 ...
分类:
其他好文 时间:
2020-06-21 12:00:07
阅读次数:
45
The set [1,2,3,...,n] contains a total of n! unique permutations. By listing and labeling all of the permutations in order, we get the following seque ...
分类:
其他好文 时间:
2020-06-21 10:13:55
阅读次数:
48
数字 n 代表生成括号的对数,请你设计一个函数,用于能够生成所有可能的并且 有效的 括号组合。 ...
分类:
其他好文 时间:
2020-06-21 09:14:33
阅读次数:
62
题目描述 给定两个二叉树,编写一个函数来检验它们是否相同。 如果两个树在结构上相同,并且节点具有相同的值,则认为它们是相同的。 示例: 输入: 1 1 / \ / \ 2 3 2 3 [1,2,3], [1,2,3] 输出: true 输入: 1 1 / \ 2 2 [1,2], [1,null,2 ...
分类:
其他好文 时间:
2020-06-21 00:47:05
阅读次数:
64