
Sort
文章平均质量分 73
zshouyi
这个作者很懒,什么都没留下…
展开
-
242. Valid Anagram
Given two strings s and t, write a function to determine if t is an anagram of s.For example,s = "anagram", t = "nagaram", return true.s = "rat", t = "car", return false.Note:You may ass原创 2017-01-03 12:34:22 · 264 阅读 · 0 评论 -
324. Wiggle Sort II
Given an unsorted array nums, reorder it such that nums[0] nums[2] .Example:(1) Given nums = [1, 5, 1, 1, 6, 4], one possible answer is [1, 4, 1, 5, 1, 6]. (2) Given nums = [1, 3, 2, 2, 3原创 2017-05-26 09:23:18 · 294 阅读 · 0 评论 -
179. Largest Number
Given a list of non negative integers, arrange them such that they form the largest number.For example, given [3, 30, 34, 5, 9], the largest formed number is 9534330.Note: The result may be ve原创 2017-05-25 12:55:32 · 244 阅读 · 0 评论 -
524. Longest Word in Dictionary through Deleting
Given a string and a string dictionary, find the longest string in the dictionary that can be formed by deleting some characters of the given string. If there are more than one possible results, retur原创 2017-04-11 02:46:28 · 284 阅读 · 0 评论 -
296. Best Meeting Point
A group of two or more people wants to meet and minimize the total travel distance. You are given a 2D grid of values 0 or 1, where each 1 marks the home of someone in the group. The distance is calcu原创 2017-04-01 02:39:42 · 309 阅读 · 0 评论 -
147. Insertion Sort List
Sort a linked list using insertion sort.linked list 的insertion sort,需要记住第一个node,以后的每一个curnode从第一个往后放到合适的位置。代码如下:/** * Definition for singly-linked list. * public class ListNode { * int va原创 2017-03-14 15:04:18 · 271 阅读 · 0 评论 -
148. Sort List
Sort a linked list in O(n log n) time using constant space complexity.这里采用merge sort。每次把linked list用slow和fast分成两段,再进行merge。代码如下:/** * Definition for singly-linked list. * public class ListNo原创 2017-03-13 09:52:08 · 202 阅读 · 0 评论 -
274. H-Index
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原创 2017-03-09 10:14:13 · 325 阅读 · 0 评论 -
75. Sort Colors
Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue.Here, we will use the integers原创 2017-02-24 07:43:02 · 298 阅读 · 0 评论 -
56. Merge Intervals
Given a collection of intervals, merge all overlapping intervals.For example,Given [1,3],[2,6],[8,10],[15,18],return [1,6],[8,10],[15,18].首先,这道题可以按照start,end来排序,以上面例子为例:start 1 2 8 1原创 2017-02-15 13:56:55 · 214 阅读 · 0 评论 -
280. Wiggle Sort
Given an unsorted array nums, reorder it in-place such that nums[0] = nums[2] .For example, given nums = [3, 5, 2, 1, 6, 4], one possible answer is [1, 6, 2, 5, 3, 4].一开始的思路,先进行快排,变成order的,在原创 2017-02-23 11:07:39 · 314 阅读 · 0 评论 -
252. Meeting Rooms
Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si < ei), determine if a person could attend all meetings.For example,Given [[0, 30],[5, 10],[原创 2017-01-27 09:22:49 · 290 阅读 · 0 评论 -
350. Intersection of Two Arrays II
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 ma原创 2017-01-05 07:42:40 · 229 阅读 · 0 评论 -
349. Intersection of Two Arrays
Given two arrays, write a function to compute their intersection.Example:Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2].Note:Each element in the result must be unique.The res原创 2017-01-04 04:07:42 · 320 阅读 · 0 评论 -
253. Meeting Rooms II
Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si < ei), find the minimum number of conference rooms required.For example,Given [[0, 30],[5,原创 2017-05-21 02:22:08 · 284 阅读 · 0 评论