Valid PalindromeGiven a string, determine if it
is a palindrome, considering only alphanumeric characters and ignoring cases.For
example,"A man, a pla...
分类:
其他好文 时间:
2014-05-12 16:27:07
阅读次数:
332
Given an unsorted array of integers, find the
length of the longest consecutive elements sequence.For example,Given[100, 4,
200, 1, 3, 2],The longest ...
分类:
其他好文 时间:
2014-05-10 20:06:26
阅读次数:
404
方法一:DFS递归,判断每一个是否为回文数1,首先要有一个判断字符串是否是回文的函数。容易实现,字符串从两边同时往中间走,看字符是否相同;2,深度优先搜索思想对字符串进行遍历。得到结果。例如,s
= "abacd"; 需要对“a”“ad”“aba”“abac”“abacd”进行深度优先搜索。深度搜索...
分类:
其他好文 时间:
2014-05-06 00:52:34
阅读次数:
388
Say you have an array for which theithelement
is the price of a given stock on dayi.Design an algorithm to find the maximum
profit. You may complete a...
分类:
其他好文 时间:
2014-05-06 00:51:29
阅读次数:
353
Mergeksorted linked lists and return it as one
sorted list. Analyze and describe its complexity.想法很简单,就是两两合并。在Merge Two Sorted
Lists这道题已经实现了两两合并的代码了,就...
分类:
其他好文 时间:
2014-05-06 00:22:01
阅读次数:
337
题目链接区间合并,贪心,需要注意边界情况,LeetCode的数据还是比较好的,这样才能写出健壮的程序。附上代码:
1 /** 2 * Definition for an interval. 3 * struct Interval { 4 * int start; 5 *
in...
分类:
其他好文 时间:
2014-05-06 00:16:44
阅读次数:
400
题目链接很简单的递推,但是写代码的过程中,犯了一个严重的错误,就是我用unsigned
int型变量>= 0 作为循环条件(而且是降序)的时候,出现了问题。附上代码: 1 class Solution { 2 public: 3 int
minimumTotal(vector > &tria...
分类:
其他好文 时间:
2014-05-06 00:10:57
阅读次数:
335
Given a binary tree containing digits from 0-9
only, each root-to-leaf path could represent a number.An example is the
root-to-leaf path 1->2->3 which...
分类:
其他好文 时间:
2014-05-05 23:55:36
阅读次数:
407
LeetCode OJGiven an array withnobjects colored
red, white or blue, sort them so that objects of the same color are adjacent,
with the colors in the or...
分类:
其他好文 时间:
2014-05-02 17:37:37
阅读次数:
468
SubsetsGiven a set of distinct integers,S,
return all possible subsets.Note:Elements in a subset must be in non-descending
order.The solution set must...
分类:
其他好文 时间:
2014-05-02 16:39:15
阅读次数:
315