摘要: Given an unsorted array nums, reorder it in-place such that nums[0] = nums[2] & nums) { if(nums == NULL || nums.size() nums[i-1])) { swap(nums[i], nums[i - 1]); }... 阅读全文
posted @ 2017-02-12 17:23 copperface 阅读(140) 评论(0) 推荐(0) 编辑
摘要: Given an array of citations (each citation is a non-negative integer) of a researcher, write a function to compute the researcher's h-index.According to the definition of h-index on Wikipedia: "A scie... 阅读全文
posted @ 2017-02-12 17:03 copperface 阅读(272) 评论(0) 推荐(0) 编辑
摘要: Given a target number, a non-negative integer k and an integer array A sorted in ascending order, find the k closest numbers to target in A, sorted in ascending order by the difference between the num... 阅读全文
posted @ 2017-02-12 14:38 copperface 阅读(345) 评论(0) 推荐(0) 编辑
摘要: Given a target number and an integer array A sorted in ascending order, find the index i in A such that A[i] is closest to the given target.Return -1 if there is no element in the array.分析使用binary Sea... 阅读全文
posted @ 2017-02-12 13:55 copperface 阅读(275) 评论(0) 推荐(0) 编辑
摘要: For a given sorted array (ascending order) and a target number, find the first index of this number in O(log n) time complexity.If the target number does not exist in the array, return -1.来源: http://w... 阅读全文
posted @ 2017-02-12 13:32 copperface 阅读(209) 评论(0) 推荐(0) 编辑
摘要: Find any position of a target number in a sorted array. Return -1 if target does not exist.与题目 First Position of Target 相同12345678910111213141516171819202122public class Solution { /** * @param... 阅读全文
posted @ 2017-02-12 13:21 copperface 阅读(172) 评论(0) 推荐(0) 编辑