2014年4月1日

【各种排序系列之】归并排序

摘要: 转载自:白话经典算法系列之五 归并排序的实现普通的合并两个数组的代码:O(n) 1 //将有序数组a[]和b[]合并到c[]中 2 void MemeryArray(int a[], int n, int b[], int m, int c[]) 3 { 4 int i, j, k; 5 6 i = j = k = 0; 7 while (i < n && j < m) 8 { 9 if (a[i] < b[j])10 c[k++] = a[i++];11 else12 c[k++... 阅读全文

posted @ 2014-04-01 21:18 Allen Blue 阅读(171) 评论(0) 推荐(0) 编辑

【LeetCode练习题】Candy

摘要: 分糖果There areNchildren standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requirements:Each child must have at least one candy.Children with a higher rating get more candies than their neighbors.What is the minimum candies you 阅读全文

posted @ 2014-04-01 21:09 Allen Blue 阅读(168) 评论(0) 推荐(0) 编辑

【LeetCode练习题】Minimum Window Substring

摘要: 找出包含子串的最小窗口Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).For example,S="ADOBECODEBANC"T="ABC"Minimum window is"BANC".Note:If there is no such window in S that covers all characters in T, retur 阅读全文

posted @ 2014-04-01 20:34 Allen Blue 阅读(250) 评论(0) 推荐(0) 编辑

【LeetCode练习题】Partition List

摘要: Given a linked list and a valuex, partition it such that all nodes less thanxcome before nodes greater than or equal tox.You should preserve the original relative order of the nodes in each of the two partitions.For example,Given1->4->3->2->5->2andx= 3,题目意思为:给定一个链表和一个数,把这个链表中比这个数小的数全放 阅读全文

posted @ 2014-04-01 20:17 Allen Blue 阅读(191) 评论(0) 推荐(0) 编辑

导航