最小路径和。题意是给一个二维矩阵,每个格子上都有一个非负整数。请找出一条从左上角到右下角的路径,使得路径上的数字总和为最小。例子, Example: Input: [ [1,3,1], [1,5,1], [4,2,1] ] Output: 7 Explanation: Because the pat ...
分类:
其他好文 时间:
2020-03-22 12:25:55
阅读次数:
67
2.(101)对称二叉树 2020年3月20日 Symmetric Tree Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, thi ...
分类:
其他好文 时间:
2020-03-21 21:50:27
阅读次数:
86
Write a program to find the n-th ugly number. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. Example: Input: n = 10 Outpu ...
分类:
其他好文 时间:
2020-03-21 19:41:35
阅读次数:
75
题目描述 An inorder binary tree traversal can be implemented in a non recursive way with a stack. For example, suppose that when a 6 node binary tree (wit ...
分类:
其他好文 时间:
2020-03-21 18:17:53
阅读次数:
52
问题:求给定数列中,最短子数列,使子数列之和>=给定值s Example: Input: s = 7, nums = [2,3,1,2,4,3] Output: 2 Explanation: the subarray [4,3] has the minimal length under the pr ...
分类:
其他好文 时间:
2020-03-21 15:07:57
阅读次数:
98
同https://www.cnblogs.com/habibah-chang/p/12538877.html 附加条件,允许重复数值。 Example 1: Input: [1,3,5] Output: 1 Example 2: Input: [2,2,2,0,1] Output: 0 方法: 思想 ...
分类:
其他好文 时间:
2020-03-21 14:54:19
阅读次数:
57
问题:求一个数列中,出现次数>n/3次的数字 Example 1: Input: [3,2,3] Output: [3] Example 2: Input: [1,1,1,3,3,2,2,2] Output: [1,2] 方法: 占权重法 出现次数>n/3,则可能出现最多两个结果。 将两个待选结果设 ...
分类:
其他好文 时间:
2020-03-21 14:33:14
阅读次数:
43
原题链接在这里:https://leetcode.com/problems/rotate-string/ 题目: We are given two strings, A and B. A shift on A consists of taking string A and moving the le ...
分类:
其他好文 时间:
2020-03-21 14:31:02
阅读次数:
42
1. static关键字修饰变量 被static修饰的成员变量叫做静态变量,也叫做类变量,说明这个变量是属于这个类的,而不是属于是对象, 没有被static修饰的成员变量叫做实例变量,说明这个变量是属于某个具体的对象的。 public class Example{ private static in ...
分类:
编程语言 时间:
2020-03-20 21:54:29
阅读次数:
59
二叉搜索树中第K小的元素。题目即是题意。例子, Example 1: Input: root = [3,1,4,null,2], k = 1 3 / \ 1 4 \ 2 Output: 1 Example 2: Input: root = [5,3,6,2,4,null,null,1], k = 3 ...
分类:
其他好文 时间:
2020-03-20 09:21:35
阅读次数:
64