摘要: 1. 二分查找 非递归 递归 2. 变形 查找第一个值等于给定值的元素 3. 变形 查找最后一个值等于给定值的元素 4.变形 查找第一个大于等于给定值的元素 5. 变形 查找最后一个小于等于给定值的元素 上一个变形的结果-1,或使用 相关题 LeetCode704 - Binary Search h 阅读全文
posted @ 2019-06-14 15:20 月半榨菜 阅读(125) 评论(0) 推荐(0)
摘要: Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in or 阅读全文
posted @ 2019-06-14 15:11 月半榨菜 阅读(69) 评论(0) 推荐(0)
摘要: Given an array of integers nums sorted in ascending order, find the starting and ending position of a given target value. Your algorithm's runtime com 阅读全文
posted @ 2019-06-14 14:57 月半榨菜 阅读(76) 评论(0) 推荐(0)
摘要: Given a sorted (in ascending order) integer array nums of n elements and a targetvalue, write a function to search target in nums. If target exists, t 阅读全文
posted @ 2019-06-14 11:29 月半榨菜 阅读(85) 评论(0) 推荐(0)