sort
文章平均质量分 79
Yingying_code
这个作者很懒,什么都没留下…
展开
-
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-01-13 21:45:38 · 220 阅读 · 0 评论 -
148. Sort List**
Sort a linked list in O(n log n) time using constant space complexity.public class Solution { public ListNode sortList(ListNode head) { if(head ==null ||head.next==null) return head;原创 2017-01-13 22:02:08 · 163 阅读 · 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-01-13 22:15:33 · 217 阅读 · 0 评论 -
451. Sort Characters By Frequency**
Given a string, sort it in decreasing order based on the frequency of characters.Example 1:Input:"tree"Output:"eert"Explanation:'e' appears twice while 'r' and 't' both appear once.So 'e'原创 2017-01-11 19:22:21 · 575 阅读 · 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-01-12 22:51:43 · 217 阅读 · 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-01-12 23:24:05 · 243 阅读 · 0 评论 -
215. Kth Largest Element in an Array**
public int findKthLargest(int[] nums, int k) { PriorityQueue pq = new PriorityQueue(); for(int i=0;i<nums.length;i++){ pq.offer(nums[i]); }原创 2017-01-12 00:34:38 · 185 阅读 · 0 评论 -
八大排序算法 java
冒泡排序 冒泡排序是一种简单的排序算法。它重复地走访过要排序的数列,一次比较两个元素,如果他们的顺序错误就把他们交换过来。走访数列的工作是重复地进行直到没有再需要交换,也就是说该数列已经排序完成。这个算法的名字由来是因为越小的元素会经由交换慢慢“浮”到数列的顶端。 冒泡排序的示例: 冒泡排序的算法实现如下:【排序后,数组从小到大排列】 /**转载 2017-03-06 22:39:46 · 417 阅读 · 0 评论