![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
leetcode之binSearch&Sort
Shawn_Redemption
这个作者很懒,什么都没留下…
展开
-
【Leetcode】Search Insert Position
题目让找出target存在的位置,如果bu'cun public int searchInsert(int[] A, int target) { int left=0; int right=A.length-1; while(left<=right) { int middle=(left+right)/2;原创 2014-10-21 03:15:28 · 366 阅读 · 0 评论 -
【Leetcode】Sort Colors
此题要求三种颜色排序,相邻的排在一块。直接ji'shu'paixu原创 2014-10-22 02:12:06 · 349 阅读 · 0 评论 -
【Leetcode】Search for a Range
Given a sorted array of integers, 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).这道题让寻找一个sou原创 2014-10-24 23:27:46 · 352 阅读 · 0 评论 -
【Leetcode】Search in Rotated Sorted Array
这道题让在旋转数组中找mu'b原创 2014-10-21 04:00:06 · 290 阅读 · 0 评论 -
【Leetcode】Search in Rotated Sorted Array II
不同的是,这道题中出现的重复的元素,所以情况更加复杂一些如果原创 2014-10-21 09:21:09 · 273 阅读 · 0 评论 -
【Leetcode】Search a 2D Matrix
这道题是让在一个二维数组里搜索特定的数数组的行和列元素全部递增且上一行的最后一个yuan's原创 2014-10-25 02:00:36 · 332 阅读 · 0 评论 -
【Leetcode】Find Minimum in Rotated Sorted Array
这道题的思路是直接找旋转数组中的最小值原创 2014-10-22 09:19:10 · 374 阅读 · 0 评论 -
【Leetcode】Find Minimum in Rotated Sorted Array II
这道题的思路是直接找旋转数组中的最小值目标是通过移动左指针让左指针到达最小值情况讨论:情况1:num[left]情况2:num[left]>num[middle],最小值一定在这里,所以去left~middle里找情况3:num[left]==num[middle],指针重合,这个时候最小值一定是left+1(详见边界问题分析)原创 2014-10-24 03:32:23 · 281 阅读 · 0 评论 -
【Leetcode】Sqrt(x)
定理1: Sqrt(x)>=1. when x>=1; Sqrt(x)原创 2014-10-22 08:40:31 · 318 阅读 · 0 评论 -
【Leetcode】Pow(x,n)
定理n^2k = (n^k)*(n^k);原创 2014-10-25 03:00:18 · 337 阅读 · 0 评论 -
【Leetcode】Merge Sorted Array
Given two sorted integer arrays A and B, merge B into A as one sorted array.Note:You may assume that A has enough space (size that is greater or equal to m + n) to hold additional elements from原创 2014-10-29 07:14:10 · 270 阅读 · 0 评论