同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
A. Bad Ugly Numbers time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given a integ ...
分类:
其他好文 时间:
2020-03-20 12:47:21
阅读次数:
68
整数转换英文表示。题意是给一个整数,请转换成英文表示。例子, Example 1: Input: 123 Output: "One Hundred Twenty Three" Example 2: Input: 12345 Output: "Twelve Thousand Three Hundred ...
分类:
其他好文 时间:
2020-03-19 09:30:00
阅读次数:
67
题目: Given a 32-bit signed integer, reverse digits of an integer. Example 1: Input: 123 Output: 321 Example 2: Input: -123 Output: -321 Example 3: Inpu ...
分类:
其他好文 时间:
2020-03-18 23:36:39
阅读次数:
72
二叉树的最大路径和。题意是给一个二叉树,节点是数字,请输出一个最大的路径和。例子, Example 1: Input: [1,2,3] 1 / \ 2 3 Output: 6 Example 2: Input: [-10,9,20,null,null,15,7] -10 / \ 9 20 / \ 1 ...
分类:
其他好文 时间:
2020-03-18 15:15:37
阅读次数:
58
最长同值路径。题意是给一个二叉树,请输出一个最长的同值路径的长度。例子, Example 1: Input: 5 / \ 4 5 / \ \ 1 1 5 Output: 2 Example 2: Input: 1 / \ 4 5 / \ \ 4 4 5 Output: 2 思路是后序遍历,可参考25 ...
分类:
其他好文 时间:
2020-03-18 09:19:03
阅读次数:
57
下一个更大的元素III。版本三其实跟前两个版本几乎没什么关系,是一道找next permutation的题。题意是给一个整数,请找出Integer范围内用到相同数字但是比当前数字大的数字。例子, Example 1: Input: 12 Output: 21 Example 2: Input: 21 ...
分类:
其他好文 时间:
2020-03-16 09:26:43
阅读次数:
36
问题: 给出给定数组的描述: Example 1: Input: [0,1,2,4,5,7] Output: ["0->2","4->5","7"] Explanation: 0,1,2 form a continuous range; 4,5 form a continuous range. Ex ...
分类:
其他好文 时间:
2020-03-15 15:03:03
阅读次数:
53
问题: 求给定数组中,连续k个数的最大平均值。 Input: [1,12,-5,-6,50,3], k = 4 Output: 12.75 Explanation: Maximum average is (12-5-6+50)/4 = 51/4 = 12.75 Note: 1 <= k <= n < ...
分类:
其他好文 时间:
2020-03-15 13:42:22
阅读次数:
67