Binary Search
liujunlovecs
这个作者很懒,什么都没留下…
展开
-
Leetcode#4||Median of Two Sorted Arrays
public class Solution { public double findMedianSortedArrays(int[] nums1, int[] nums2) { int len1 = nums1.length; int len2 = nums2.length; if ((len1 + len2) % 2 ==原创 2015-08-11 10:44:40 · 214 阅读 · 0 评论 -
Leetcode#29||Divide Two Integers
public class Solution { public int divide(int dividend, int divisor) { if (divisor == 0) { return Integer.MAX_VALUE; } if (divisor == -1 && dividend == Integer.原创 2015-08-13 08:28:09 · 225 阅读 · 0 评论 -
Leetcode#33||Search in Rotated Sorted Array
public class Solution { public int search(int[] nums, int target) { if (nums == null || nums.length < 1) { return -1; } int length = nums.length;原创 2015-08-14 17:18:03 · 211 阅读 · 0 评论 -
Leetcode#34||Search for a Range
public class Solution { public int[] searchRange(int[] nums, int target) { int[] result = {-1, -1}; if (nums == null || nums.length < 1) { return result;原创 2015-08-14 17:18:50 · 265 阅读 · 0 评论 -
Leetcode#35||Search Insert Position
public class Solution { public int searchInsert(int[] nums, int target) { if (nums == null || nums.length < 1) { return -1; } int length = nums.length;原创 2015-08-14 18:04:23 · 202 阅读 · 0 评论 -
Leetcode#50||Pow (x, n)
public class Solution { public double myPow(double x, int n) { if (n < 0) { return 1 / pow(x, -n); } else { return pow(x, n); } }原创 2015-08-17 10:13:52 · 260 阅读 · 0 评论 -
Leetcode#69||Sqrt(x)
public class Solution { public int mySqrt(int x) { if (x < 0) { return -1; } int left = 1; int right = x; while (left <= right原创 2015-08-18 15:36:59 · 237 阅读 · 0 评论 -
Leetcode#74||Search a 2D Matrix
public class Solution { public boolean searchMatrix(int[][] matrix, int target) { if (matrix == null || matrix.length == 0 || matrix[0].length == 0) { return false; }原创 2015-08-19 07:55:22 · 313 阅读 · 0 评论