上一页 1 2 3 4 5 6 7 8 9 ··· 19 下一页
摘要: Given an array of strings, group anagrams together.For example, given: ["eat", "tea", "tan", "ate", "nat", "bat"], Return:[ ["ate", "eat","tea"], ["nat","tan"], ["bat"] ]Note: All 阅读全文
posted @ 2017-02-13 14:40 copperface 阅读(227) 评论(0) 推荐(0) 编辑
摘要: 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) 编辑
摘要: Given two arrays, write a function to compute their intersection.Example:Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2, 2].Note:Each element in the result should appear as many times as it sho... 阅读全文
posted @ 2017-02-11 15:11 copperface 阅读(276) 评论(0) 推荐(0) 编辑
摘要: Given an integer array, sort it in ascending order. Use selection sort, bubble sort, insertion sort or any O(n2) algorithm.分析bubble sort1234567891011121314151617181920public class Solution { /** ... 阅读全文
posted @ 2017-02-10 22:31 copperface 阅读(150) 评论(0) 推荐(0) 编辑
摘要: Given an integer array, sort it in ascending order. Use quick sort, merge sort, heap sort or any O(nlogn) algorithm.分析Quick Sortindex 0 1 2 3 4 5 6 7 8 9 10 11 12 13A(key=3)4 1 2 1 5 1 3 2 3 6 2 1... 阅读全文
posted @ 2017-02-10 22:31 copperface 阅读(206) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 9 ··· 19 下一页