![](https://img-blog.csdnimg.cn/20190918140145169.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
BinarySearch
weixin_39145266
这个作者很懒,什么都没留下…
展开
-
209 Minimum Size Subarray Sum
1 题目Given an array ofnpositive integers and a positive integers, find the minimal length of acontiguoussubarray of which the sum ≥s. If there isn't one, return 0 instead.Example:Input: s...原创 2019-03-30 11:52:54 · 46 阅读 · 0 评论 -
392 Is Subsequence
Given a stringsand a stringt, check ifsis subsequence oft.You may assume that there is only lower case English letters in bothsandt.tis potentially a very long (length ~= 500,000) string,...原创 2019-07-09 21:50:24 · 58 阅读 · 0 评论 -
374 Guess Number Higher or Lower
1 题目We are playing the Guess Game. The game is as follows:I pick a number from1ton. You have to guess which number I picked.Every time you guess wrong, I'll tell you whether the number is hig...原创 2019-05-08 16:11:45 · 83 阅读 · 0 评论 -
211 Add and Search Word - Data structure design
1 题目Design a data structure that supports the following two operations:void addWord(word)bool search(word)search(word) can search a literal word or a regular expression string containing only l...原创 2019-04-24 14:20:38 · 67 阅读 · 0 评论 -
300 Longest Increasing Subsequence
1 题目Given an unsorted array of integers, find the length of longest increasing subsequence.Example:Input: [10,9,2,5,3,7,101,18]Output: 4 Explanation: The longest increasing subsequence is [2,...原创 2019-04-24 13:22:17 · 49 阅读 · 0 评论 -
220 Contains Duplicate III
1 题目Given an array of integers, find out whether there are two distinct indices i and j in the array such that the absolute difference between nums[i] and nums[j] is at most t and the absolute diff...原创 2019-04-23 16:05:45 · 74 阅读 · 0 评论 -
81 Search in Rotated Sorted Array II
1 题目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...原创 2019-04-15 14:42:11 · 55 阅读 · 0 评论 -
162 Find Peak Element
1 题目A peak element is an element that is greater than its neighbors.Given an input array nums, where nums[i] ≠ nums[i+1], find a peak element and return its index.The array may contain multiple...原创 2019-04-23 10:20:15 · 54 阅读 · 0 评论 -
275 H-Index II
1 题目Given an array of citations sorted in ascending order (each citation is a non-negative integer) of a researcher, write a function to compute the researcher's h-index.According to the definiti...原创 2019-04-22 15:49:50 · 80 阅读 · 0 评论 -
222 Count Complete Tree Nodes
1 题目Given a complete binary tree, count the number of nodes.Note:Definition of a complete binary tree from Wikipedia:In a complete binary tree every level, except possibly the last, is complet...原创 2019-04-22 14:33:49 · 64 阅读 · 0 评论 -
50 Pow(x, n)
Implementpow(x,n), which calculatesxraised to the powern(xn).Example 1:Input: 2.00000, 10Output: 1024.00000Example 2:Input: 2.10000, 3Output: 9.26100Example 3:Input: 2.00000, ...原创 2019-04-03 12:42:13 · 73 阅读 · 0 评论 -
153 Find Minimum in Rotated Sorted Array
1 题目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 assum...原创 2019-04-08 11:55:30 · 61 阅读 · 0 评论 -
74 Search a 2D Matrix
1 题目Write an efficient algorithm that searches for a value in anmxnmatrix. This matrix has the following properties:Integers in each row are sorted from left to right. The first integer of ea...原创 2019-03-29 09:18:10 · 58 阅读 · 0 评论 -
29 Divide Two Integers
1 题目Given two integersdividendanddivisor, divide two integers without using multiplication, division and mod operator.Return the quotient after dividingdividendbydivisor.The integer divisi...原创 2019-03-29 09:18:55 · 114 阅读 · 0 评论 -
287 Find the Duplicate Number
1 题目Given an arraynumscontainingn+ 1 integers where each integer is between 1 andn(inclusive), prove that at least one duplicate number must exist. Assume that there is only one duplicate numbe...原创 2019-03-30 12:25:01 · 78 阅读 · 0 评论 -
378 Kth Smallest Element in a Sorted Matrix Medium
1 题目Given anxnmatrix where each of the rows and columns are sorted in ascending order, find the kth smallest element in the matrix.Note that it is the kth smallest element in the sorted order,...原创 2019-07-10 20:37:32 · 68 阅读 · 0 评论