二分查找
csdnzhaocsdn
先通俗易懂
再简洁高效
菜但步履不停
所有文章只是学习用没有任何商业盈利若侵权我删
展开
-
300. 最长上升子序列
给定一个无序的整数数组,找到其中最长上升子序列的长度。 示例: 输入: [10,9,2,5,3,7,101,18] 输出: 4 解释: 最长的上升子序列是 [2,3,7,101],它的长度是 4。 说明: 可能会有多种最长上升子序列的组合,你只需要输出对应的长度即可。 你算法的时间复杂度应该为 O(n2) 。 进阶: 你能将算法的时间复杂度降低到 O(n log n) 吗? 来源:力扣(LeetC...原创 2020-02-20 09:15:57 · 90 阅读 · 0 评论 -
153. Find Minimum in Rotated Sorted Array
Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2]). Find the minimum element. You may assume no dupli...原创 2020-02-13 11:40:51 · 53 阅读 · 0 评论 -
81. Search in Rotated Sorted Array II
Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., [0,0,1,2,2,5,6] might become [2,5,6,0,0,1,2]). You are given a target value to search. If found in...原创 2020-02-13 11:10:10 · 55 阅读 · 0 评论 -
74. Search a 2D Matrix
Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sorted from left to right. The first integer of each row i...原创 2020-02-13 10:50:13 · 39 阅读 · 0 评论 -
34. Find First and Last Position of Element in Sorted Array
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 complexity must be in the order of O(log n). If the t...原创 2020-02-12 17:27:12 · 40 阅读 · 0 评论 -
33. Search in Rotated Sorted Array
Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2]). You are given a target value to search. If found in...原创 2020-02-12 17:00:13 · 39 阅读 · 0 评论 -
270. Closest Binary Search Tree Value
Given two integers dividend and divisor, divide two integers without using multiplication, division and mod operator. Return the quotient after dividing dividend by divisor. The integer division shoul...原创 2020-02-12 12:28:31 · 74 阅读 · 0 评论