http://www.lintcode.com/en/problem/longest-increasing-continuous-subsequence-ii/# Give you an integer matrix (with row size n, column size m),find the...
分类:
其他好文 时间:
2015-05-26 17:54:40
阅读次数:
123
http://www.lintcode.com/en/problem/longest-increasing-continuous-subsequence/# Give you an integer array (index from 0 to n-1, where n is the size of ...
分类:
其他好文 时间:
2015-05-26 12:19:11
阅读次数:
144
Design an algorithm and write code to serialize and deserialize a binary tree. Writing the tree to a file is called 'serialization' and reading back f...
分类:
其他好文 时间:
2015-05-25 20:08:17
阅读次数:
358
Given a collection of numbers that might contain duplicates, return all possible unique permutations. For example, [1,1,2] have the following unique p...
分类:
其他好文 时间:
2015-05-24 01:22:23
阅读次数:
908
给定一个若干整数的排列,给出按正数大小进行字典序从小到大排序后的下一个排列。
如果没有下一个排列,则输出字典序最小的序列。
样例
左边是原始排列,右边是对应的下一个排列。
1,2,3 → 1,3,2
3,2,1 → 1,2,3
1,1,5 → 1,5,1
挑战
不允许使用额外的空间。
分析:从后往前找,找到第一对(i,j),使得nums[i]
...
分类:
其他好文 时间:
2015-05-23 16:59:49
阅读次数:
110
假设你是一个专业的窃贼,准备沿着一条街打劫房屋。每个房子都存放着特定金额的钱。你面临的唯一约束条件是:相邻的房子装着相互联系的防盗系统,且 当相邻的两个房子同一天被打劫时,该系统会自动报警。
给定一个非负整数列表,表示每个房子中存放的钱, 算一算,如果今晚去打劫,你最多可以得到多少钱 在不触动报警装置的情况下。
样例
给定 [3, 8, 4],
返回 8.
挑战...
分类:
其他好文 时间:
2015-05-23 16:52:36
阅读次数:
394
有 n 个不同价值的硬币排成一条线。两个参赛者轮流从右边依次拿走 1 或 2 个硬币,直到没有硬币为止。计算两个人分别拿到的硬币总价值,价值高的人获胜。
请判定 第一个玩家 是输还是赢?
样例
给定数组 A = [1,2,2],
返回 true.
给定数组 A = [1,2,4],
返回 false.
分析:肯定还是动态规划问题,而已可以知道dp[i]肯定和d...
分类:
其他好文 时间:
2015-05-23 12:57:18
阅读次数:
169
问题描述Say you have an array for which the ith element is the price of a given stock on day i.
Design an algorithm to find the maximum profit. You may complete at most k transactions.Example
Given price...
分类:
其他好文 时间:
2015-05-23 11:30:26
阅读次数:
124
There are n coins in a line. Two players take turns to take a coin from one of the ends of the line until there are no more coins left. The player with the larger amount of money wins.
Could you pl...
分类:
其他好文 时间:
2015-05-23 00:02:42
阅读次数:
646
http://www.lintcode.com/en/problem/permutations/# Given a list of numbers, return all possible permutations. Example For nums = [1,2,3], the permutati...
分类:
其他好文 时间:
2015-05-22 23:55:47
阅读次数:
604