
search
文章平均质量分 80
smallfish_yy
人最幸福的事之一就是把爱好变成自己的工作。
展开
-
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-01-17 13:34:48 · 479 阅读 · 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原创 2013-12-29 08:53:02 · 465 阅读 · 0 评论 -
3Sum
Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero. Note: Elements in a triplet (a,b,c原创 2014-01-31 01:42:00 · 420 阅读 · 0 评论 -
3Sum Closest
Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exact原创 2014-01-31 01:44:15 · 419 阅读 · 0 评论 -
Two Sum
Given an array of integers, find two numbers such that they add up to a specific target number. The function twoSum should return indices of the two numbers such that they add up to the target, whe原创 2014-01-03 05:37:58 · 443 阅读 · 0 评论 -
Pow(x, n)
Implement pow(x, n). Analysis: public class Solution { public double power(double x, int n) { if(n==0) return 1; double y = power(x, n/2); if(n%2==0) return y*y;原创 2014-02-10 02:59:28 · 373 阅读 · 0 评论 -
Search in Rotated Sorted Array II
Follow up for "Search in Rotated Sorted Array": What if duplicates are allowed? Would this affect the run-time complexity? How and why? Write a function to determine if a given target is in the原创 2014-01-21 10:39:24 · 449 阅读 · 0 评论