摘要:
问题:求一个数列中,出现次数>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,则可能出现最多两个结果。 将两个待选结果设 阅读全文
摘要:
问题:求给定数列中,最短子数列,使子数列之和>=给定值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 阅读全文
摘要:
问题:求数组的任意峰值。两侧都从-∞开始向上递增。 Example 1: Input: nums = [1,2,3,1] Output: 2 Explanation: 3 is a peak element and your function should return the index numb 阅读全文
摘要:
同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 方法: 思想 阅读全文
摘要:
问题:求被旋转了的排序数列中的最小值。 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的中间值 阅读全文