题目:(Sort)Given an unsorted array, find the maximum difference between the successive elements in its sorted form.Try to solve it in linear time/space....
分类:
其他好文 时间:
2014-12-30 01:45:54
阅读次数:
195
1 题目描述Given an array of sizen, find the majority element. The majority element is the element that appears more than? n/2 ?times.You may assume that t...
分类:
其他好文 时间:
2014-12-24 17:54:57
阅读次数:
147
注意: 限制条件: 先买后卖(不同天)。
思想: 买了后,1. 若以后价格不变,不买不卖。 1. 更价格低,重新买。2. 价格升高,假定抛售,更新一下利润值。
思想:求出所有非递减序列两端绝对值之和。我贴在 leedcode 的代码和证明:
思想:动态规划。 记录下从各位置(含)开始之前...
分类:
其他好文 时间:
2014-08-27 16:00:18
阅读次数:
213
Sort a linked list using insertion sort. 1 /**
2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 *
ListNode *nex...
分类:
其他好文 时间:
2014-06-10 12:14:19
阅读次数:
253
题目链接题意: find the maximum positive difference
between the price on the ith day and the jth day附上代码: 1 class Solution { 2
public: 3 int maxProfit(ve...
分类:
其他好文 时间:
2014-05-28 03:49:45
阅读次数:
307