75. Sort Colors

2016-06-21
阅读 2 分钟
2.9k
题目: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.

147. Insertion Sort List

2016-06-21
阅读 1 分钟
2.7k
注意新的list跟原来的list是不相连的,然后把各个状态的点记录好就行: {代码...}

179. Largest Number

2016-06-21
阅读 1 分钟
2.2k
这道题开始想容易陷入一个误区:我要怎么比较这两个单独的数,使得它们拼起来的结果最大呢?然而如果真的仔细比较这两个数最后得出一个结论,代码会很长,楼主已经试过了。。。后来转念一想,直接比较两个数拼成的结果不就好了,长度一样,所以省去了很多麻烦。程序如下:

148. Sort List

2016-06-20
阅读 2 分钟
3.5k
题目:Sort a linked list in O(n log n) time using constant space complexity.

354. Russian Doll

2016-06-17
阅读 2 分钟
3.4k
典型的dp,注意点的程序中已经标出: {代码...}

265. Paint House II

2016-06-16
阅读 3 分钟
3.3k
题目:There are a row of n houses, each house can be painted with one of the k colors. The cost of painting each house with a certain color is different. You have to paint all the houses such that no two adjacent houses have the same color.

256. Paint House

2016-06-16
阅读 2 分钟
2.7k
题目:here are a row of n houses, each house can be painted with one of the three colors: red, blue or green. The cost of painting each house with a certain color is different. You have to paint all the houses such that no two adjacent houses have the same color.

276. Paint Fence

2016-06-16
阅读 2 分钟
2.7k
题目:There is a fence with n posts, each post can be painted with one of the k colors.

343. Integer Break

2016-06-16
阅读 2 分钟
2.9k
题目:Given a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum product you can get.

300. Longest Increasing Subsequence

2016-06-14
阅读 1 分钟
2.8k
题目:Given an unsorted array of integers, find the length of longest increasing subsequence.

264. Ugly NumberII & 313. Super Ugly Number

2016-06-14
阅读 3 分钟
3.4k
Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 1, 2, 3, 4, 5, 6, 8, 9, 10, 12 is the sequence of the first 10 ugly numbers.

174. Dungeon Game

2016-06-14
阅读 3 分钟
2.6k
The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of M x N rooms laid out in a 2D grid. Our valiant knight (K) was initially positioned in the top-left room and must fight his way through the dungeon to rescue the princess.

221. Maximal Square

2016-06-13
阅读 2 分钟
2.5k
题目:Given a 2D binary matrix filled with 0's and 1's, find the largest square containing all 1's and return its area.