上一页 1 ··· 33 34 35 36 37 38 39 40 41 ··· 44 下一页
摘要: 问题:求一个数列中,出现次数>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,则可能出现最多两个结果。 将两个待选结果设 阅读全文
posted @ 2020-03-21 14:00 habibah_chang 阅读(94) 评论(0) 推荐(0) 编辑
摘要: 问题:求给定数列中,最短子数列,使子数列之和>=给定值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 阅读全文
posted @ 2020-03-21 13:34 habibah_chang 阅读(87) 评论(0) 推荐(0) 编辑
摘要: 问题:求数组的任意峰值。两侧都从-∞开始向上递增。 Example 1: Input: nums = [1,2,3,1] Output: 2 Explanation: 3 is a peak element and your function should return the index numb 阅读全文
posted @ 2020-03-21 13:27 habibah_chang 阅读(131) 评论(0) 推荐(0) 编辑
摘要: 同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 方法: 思想 阅读全文
posted @ 2020-03-21 13:20 habibah_chang 阅读(142) 评论(0) 推荐(0) 编辑
摘要: 问题:求被旋转了的排序数列中的最小值。 Example 1: Input: [3,4,5,1,2] Output: 1 Example 2: Input: [4,5,6,7,0,1,2] Output: 0 方法:二分法查找 low=0,high=end index mid=low和high的中间值 阅读全文
posted @ 2020-03-21 13:11 habibah_chang 阅读(99) 评论(0) 推荐(0) 编辑
摘要: 问题: 给出给定数组的描述: 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 阅读全文
posted @ 2020-03-15 14:41 habibah_chang 阅读(109) 评论(0) 推荐(0) 编辑
摘要: 问题:给定数组中,能否最多修改一个数,使得数组成为非减数组,即对数组中任意相邻两数:nums[i] <= nums[i+1] Example 1: Input: [4,2,3] Output: True Explanation: You could modify the first 4 to 1 t 阅读全文
posted @ 2020-03-15 14:09 habibah_chang 阅读(135) 评论(0) 推荐(0) 编辑
摘要: 问题: 处理给定数组,(平滑处理)使得每个元素=周围+自己共9个元素的平均值。(若没有9个元素,则是周围一圈+自己元素的平均值) Input: [[1,1,1], [1,0,1], [1,1,1]] Output: [[0, 0, 0], [0, 0, 0], [0, 0, 0]] Explanat 阅读全文
posted @ 2020-03-15 13:38 habibah_chang 阅读(92) 评论(0) 推荐(0) 编辑
摘要: 问题: 求给定数组中,连续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 < 阅读全文
posted @ 2020-03-15 12:18 habibah_chang 阅读(100) 评论(0) 推荐(0) 编辑
摘要: 问题:求一个数列里三个数相乘的最大值 Input: [1,2,3] Output: 6 Input: [1,2,3,4] Output: 24 Note: 1.The length of the given array will be in range [3,104] and all element 阅读全文
posted @ 2020-03-15 12:08 habibah_chang 阅读(128) 评论(0) 推荐(0) 编辑
上一页 1 ··· 33 34 35 36 37 38 39 40 41 ··· 44 下一页