题目: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
Given an array of integers, find two numbers such that they add up to a specific target number.
The function twoSum should return indices of the two numbers such that they add up to the target, whe...
分类:
其他好文 时间:
2014-06-09 23:14:45
阅读次数:
264
原题地址:https://oj.leetcode.com/problems/combination-sum/题意:Given
a set of candidate numbers (C) and a target number (T), find all unique
combinations in...
分类:
编程语言 时间:
2014-06-09 17:50:09
阅读次数:
333
原题地址:https://oj.leetcode.com/problems/combination-sum-ii/题意:Given
a collection of candidate numbers (C) and a target number (T), find all unique
combi...
分类:
编程语言 时间:
2014-06-09 17:41:58
阅读次数:
320
Given a sorted linked list, delete all nodes
that have duplicate numbers, leaving onlydistinctnumbers from the original
list.For example,Given1->2->3-...
分类:
其他好文 时间:
2014-06-08 21:56:41
阅读次数:
297
【题目】
Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.
For example, given the following triangle
[
[2],
[3,4],
[6,5,7],
[4,1,8,3]
]
The minimum path sum from top to...
分类:
其他好文 时间:
2014-06-08 17:52:45
阅读次数:
235
题目:For example,"A man, a plan, a canal: Panama" is a palindrome. "race a car" is not a palindrome.
解题思路:验证一个字符串是否是回文字符串。首先看看wiki上对于回文的解释:回文,亦称回环,是正读反读都能读通的句子,亦有将文字排列成圆圈者,Famous examples include "Amore, Roma", "A man, a plan, a canal: Panama" and "No 'x' in...
分类:
其他好文 时间:
2014-06-08 16:30:29
阅读次数:
235
题目
A message containing letters from A-Z is being encoded to numbers using
the following mapping:
'A' -> 1
'B' -> 2
...
'Z' -> 26
Given an encoded message containing digits, determine ...
分类:
其他好文 时间:
2014-06-08 15:30:08
阅读次数:
182
题目 :Input: numbers={2, 7, 11, 15}, target=9
Output: index1=1, index2=2
解题思路:
给出一个数组合一个数,如果两个数的和等于所给的数,求出该两个数所在数组中的位置。
这个题也挺常见的,就是两个指针,从前后两个方向扫描。但是本题有以下几个需要的点:
1. 所给数组不是有序的;
2. 返回的下标是从1开始的,并且是原来无序数组中的下标;
3. 输入数组中可能含有重复的元素。
好了,把以上三点想到的话,做这个题应该不会有啥问题。
具体方法:把原...
分类:
其他好文 时间:
2014-06-08 02:14:06
阅读次数:
250
Given an array of integers, find two numbers such that they add up to a specific target number.
The function twoSum should return indices of the two numbers such that they add up to the target, whe...
分类:
其他好文 时间:
2014-06-08 02:12:04
阅读次数:
216