题目链接地址:http://soj.me/1176题目大意:两头取数。第一个人随机取,第二个人用贪婪算法(每次都取大的),求两人取数在第一个人赢的情况下的最大分差。使用贪婪算法时,如果左右两边相等,取左边的。核心算法:动态规划。 设数组arr[a][b]是在数列区间[a,b]上的最大分差。 递推公式...
分类:
其他好文 时间:
2014-10-09 14:57:33
阅读次数:
159
1.normal fetch ----fetch 1 cache line once2. pre-fetch mode one ---- fetch 3 cache line once3.pre-fetch mode two ----{way1: fetch 3 cache lines once ,...
分类:
其他好文 时间:
2014-10-09 14:41:14
阅读次数:
196
Find the intersection of two sorted arrays.Let’s called array1 as A and array2 as B, each with size m and n.The obvious brute-force solution is to sca...
分类:
其他好文 时间:
2014-10-09 14:20:13
阅读次数:
161
The gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integernrepresenting the total number...
分类:
其他好文 时间:
2014-10-09 13:16:43
阅读次数:
179
这道题真真是在面试中碰到过,可惜当时复杂度到O(n2)了,太挫了,怪不得没有通过面试。
Given n non-negative integers a1, a2,
..., an, where each represents a point at coordinate (i, ai). n vertical
lines are drawn such that the two en...
分类:
编程语言 时间:
2014-10-09 01:58:17
阅读次数:
229
题目:Given a linked list, swap every two adjacent nodes and return its head.For example,Given1->2->3->4, you should return the list as2->1->4->3.Your al...
分类:
其他好文 时间:
2014-10-09 00:31:07
阅读次数:
234
[leetcode]There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n))....
分类:
其他好文 时间:
2014-10-08 14:00:15
阅读次数:
147
DescriptionD Anti-Rhyme Pairs Input: Standard Input Output: Standard Output Often two words that rhyme also end in the same sequence of characters. We...
分类:
其他好文 时间:
2014-10-08 11:01:35
阅读次数:
261
Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)You have t...
分类:
其他好文 时间:
2014-10-08 07:40:24
阅读次数:
228
Problem:There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity sh...
分类:
其他好文 时间:
2014-10-08 00:27:44
阅读次数:
321