码迷,mamicode.com
首页 >  
搜索关键字:binary-search 二分查找 折半查找    ( 5399个结果
[LC] 1214. Two Sum BSTs
Given two binary search trees, return True if and only if there is a node in the first tree and a node in the second tree whose values sum up to a giv ...
分类:其他好文   时间:2020-04-27 13:22:13    阅读次数:61
力扣744. 寻找比目标字母大的最小字母
class Solution { public char nextGreatestLetter(char[] letters, char target) { //二分查找 if(letters[0] > target) return letters[0]; int len = letters.len ...
分类:其他好文   时间:2020-04-26 23:54:42    阅读次数:77
分治算法(1)——二分查找、STL函数库的应用第五弹——二分函数
分治算法(1):二分查找!昨天刚说不写算法了,但是突然想起来没写过分治算法的博客,所以强迫症的我…… STL函数库第五弹——二分函数lower_bound()、upper_bound()、binary_search() 由于笔者比较懒,所以把分治算法(二分查找篇)和STL第五弹放在一起。。。 Par ...
分类:编程语言   时间:2020-04-26 01:42:28    阅读次数:75
【LeetCode】LCP 12. 小张刷题计划(二分查找)
为了提高自己的代码能力,小张制定了 LeetCode 刷题计划,他选中了 LeetCode 题库中的 n 道题,编号从 0 到 n 1,并计划在 m 天内按照题目编号顺序刷完所有的题目(注意,小张不能用多天完成同一题)。 在小张刷题计划中,小张需要用 time[i] 的时间完成编号 i 的题目。此外 ...
分类:其他好文   时间:2020-04-26 01:36:55    阅读次数:55
第k大-二分查找-1139. 第k大的子数组
2020-04-25 18:19:22 问题描述: 给定一个长度为n的数组a,它有n * (n + 1) / 2个子数组。请计算这些子数组的和,然后按照升序排列,并返回排序后第k个数。 样例 Example1 Input: [2,3,1,4] 6 Output:5 Explanation: 我们可以 ...
分类:编程语言   时间:2020-04-25 19:13:36    阅读次数:60
算法--二叉搜索树的python实现
二叉查找树(Binary Search Tree),也称为二叉搜索树、有序二叉树或排序二叉树,是指一棵空树或者具有下列性质的二叉树: 若任意节点的左子树不空,则左子树上所有节点的值均小于它的根节点的值; 若任意节点的右子树不空,则右子树上所有节点的值均大于它的根节点的值; 任意节点的左、右子树也分别 ...
分类:编程语言   时间:2020-04-23 18:45:21    阅读次数:59
算法-二分查找与树的增删改查
查找算法 二分查找 非递归版的 递归版的 floor实现 二分查找法, 在有序数组arr中, 查找target,如果找到target, 返回第一个target相应的索引index,如果没有找到target, 返回比target小的最大值相应的索引, 如果这个最大值有多个, 返回最大索引,如果这个ta ...
分类:编程语言   时间:2020-04-23 16:19:35    阅读次数:72
二分查找
二分查找 1 def binarySearch(l, t): 2 low, high = 0, len(l) - 1 3 while low < high: 4 print low, high 5 mid = (low + high) / 2 6 if l[mid] > t: 7 high = mi ...
分类:其他好文   时间:2020-04-23 11:54:46    阅读次数:44
[LeetCode in Python] 98 (M) validate binary search tree 验证二叉搜索树
题目 https://leetcode cn.com/problems/validate binary search tree/ 给定一个二叉树,判断其是否是一个有效的二叉搜索树。 假设一个二叉搜索树具有如下特征: 节点的左子树只包含小于当前节点的数。 节点的右子树只包含大于当前节点的数。 所有左子 ...
分类:编程语言   时间:2020-04-22 09:39:44    阅读次数:68
704. 二分查找
三种写法都过。 代码一: 1 class Solution(object): 2 def search(self, nums, target): 3 """ 4 :type nums: List[int] 5 :type target: int 6 :rtype: int 7 """ 8 if ta ...
分类:其他好文   时间:2020-04-22 00:33:01    阅读次数:81
5399条   上一页 1 ... 25 26 27 28 29 ... 540 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!