![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Binary Search
文章平均质量分 72
cgdong2014
这个作者很懒,什么都没留下…
展开
-
Find Minimum in Rotated Sorted Array I & II
Suppose a sorted array 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 duplicate exists in the ar原创 2015-01-10 14:34:09 · 223 阅读 · 0 评论 -
Longest Increasing Subsequence
Given a sequence of integers, find the longest increasing subsequence (LIS). You code should return the length of the LIS. Have you met this question in a real interview? Yes Exampl原创 2015-08-17 12:04:16 · 297 阅读 · 0 评论 -
Count Complete Tree Nodes
Given a complete binary tree, count the number of nodes. Definition of a complete binary tree from Wikipedia: In a complete binary tree every level, except possibly the last, is completely filled, a原创 2015-08-10 10:58:21 · 274 阅读 · 0 评论 -
Search in Rotated Sorted Array
Suppose a sorted array 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 the array return it原创 2014-10-19 12:42:38 · 211 阅读 · 0 评论 -
Binary Search Tree Iterator
Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST. Calling next() will return the next smallest number in the BST. Note: next()原创 2015-01-06 02:19:17 · 246 阅读 · 0 评论 -
Sqrt(x)
Implement int sqrt(int x). Compute and return the square root of x. 思路: 用二分法来运算。 public class Solution { public int sqrt(int x) { if(x < 0) return Integer.MIN_VALUE;原创 2015-01-01 09:59:28 · 259 阅读 · 0 评论 -
Find Minimum in Rotated Sorted Array II
Suppose a sorted array 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. The array may contain duplicates. 思原创 2014-12-31 11:01:43 · 241 阅读 · 0 评论 -
4Sum
Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target. Note: Elements原创 2015-01-19 04:06:03 · 248 阅读 · 0 评论 -
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). If the target is not found in t原创 2015-01-19 03:35:04 · 225 阅读 · 0 评论 -
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原创 2014-12-29 01:25:57 · 244 阅读 · 0 评论 -
Contains Duplicate III
Given an array of integers, find out whether there are two distinct indices i and j in the array such that the difference between nums[i] and nums[j] is at most t and the difference between i and j原创 2015-08-07 11:21:13 · 227 阅读 · 0 评论