题目:Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s.
解题思路:
回文划分,题目意思是给一个字符串,找出将字符串划分为一系列回文子串的各种可能组合。例如,一个子串“aab“,你需要返回["aa","b"],["a","a","b"]。这个题目的解法也是非常的典型---循环加递归,...
分类:
其他好文 时间:
2014-06-09 23:24:11
阅读次数:
256
Grouping Records Together Based on a Field
Problem
You
have a sequence of dictionaries or instances and you want to iterate over the data in groups based on the value of a...
分类:
编程语言 时间:
2014-06-08 18:22:29
阅读次数:
280
题目
Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between).
For example:
G...
分类:
其他好文 时间:
2014-06-08 17:29:07
阅读次数:
315
题目
Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).
For example:
Given binary tree {3,9,20,#,#,15,7},
3
/ \...
分类:
其他好文 时间:
2014-06-08 16:38:02
阅读次数:
194
Description
Farmer John wants the cows to prepare for the county jumping competition, so Bessie and the gang are practicing jumping over hurdles. They are getting tired, though, so they want to be ...
分类:
其他好文 时间:
2014-06-08 15:55:10
阅读次数:
199
uva 101 The Blocks Problem (基本算法-模拟)
题目大意:
问题就是分析一系列的命令,告诉机械臂如何操纵放在一个平台上的积木。最初平台上有n个积木(编号由0到n - 1),对于任意的0 ≤ i < n - 1,积木bi都与bi + 1相临
机械臂操作积木的有效指令列举如下:
(1)move a onto b
a和b都是积木的编号,先将a和b上面所有的积木都放回原处,再将a放在b上。
(2)move a over b
a和b都是积木的编号,先将a上面所有的积木放回原处,再将a放在b上...
分类:
其他好文 时间:
2014-06-08 15:49:01
阅读次数:
220
You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a link...
分类:
其他好文 时间:
2014-06-08 15:30:28
阅读次数:
227
题目:For example, given s = "aab",
Return 1 since the palindrome partitioning ["aa","b"] could be produced using 1 cut
解题思路:给一个字符串,如果字符串可以划分成若干子回文字符串,返回最小的划分数量。
这个题如果还用之前求所有划分组合的循环加递归方法的话,就会得到超时的错误。这是就要考虑别的方法,动态规划倒是一个不错的方法,但是动态规划最重要的是要找到动态方程。本题的动态方程:
dp[i] =...
分类:
其他好文 时间:
2014-06-08 14:56:58
阅读次数:
257
题目
Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root).
For example:
Given binary tree {3,9,20...
分类:
其他好文 时间:
2014-06-08 09:23:34
阅读次数:
230
题目
Given an array and a value, remove all instances of that value in place and return the new length.
The order of elements can be changed. It doesn't matter what you leave beyond the new length.
原题链接(点我)
解题思路
给一个数组和一个数字,移除该数字在数组中所有出现的地方。
这是一个非常简单的题目,应...
分类:
其他好文 时间:
2014-06-08 04:05:50
阅读次数:
284