【题目】
Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.
Do not allocate extra space for another array, you must do this in place with constant memory.
For example,
Given input array A ...
分类:
其他好文 时间:
2014-05-18 18:25:19
阅读次数:
272
【题目】
Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exactly one solution.
For example, given array S = {...
分类:
其他好文 时间:
2014-05-18 10:37:57
阅读次数:
269
【题目】
Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.
The brackets must close in the correct order, "()" and "()[]{}" are all valid but "(]" and "([)]" are not.
【题意】
判断给定的字符串是否是合法的...
分类:
其他好文 时间:
2014-05-18 10:08:11
阅读次数:
327
【题目】
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.
For example, given n = 3, a solution set is:
"((()))", "(()())", "(())()", "()(())", "()()()"
【题意】
给定n对括号,输出所有可行的括号组合字符串。所谓合法,就是可以Valid Pare...
分类:
其他好文 时间:
2014-05-18 09:06:41
阅读次数:
266
【题目】
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.
【题意】
合并K个有序链表
【思路】
归并
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.
For ...
分类:
其他好文 时间:
2014-05-18 09:05:40
阅读次数:
255
【题目】
Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.
Note:
Elements in a quadruplet (a,b,c,d) must be in non-descending ord...
分类:
其他好文 时间:
2014-05-18 08:46:04
阅读次数:
227
【题目】
Given a roman numeral, convert it to an integer.
Input is guaranteed to be within the range from 1 to 3999.
【题意】
把罗马数转换为整数
【思路】
罗马数字中只使用如下七个基值字母:M,D,C,L,X,V,I,分别用来表示1000、500、100、50、10、5、1。
大体思路是每个罗马字母对应的值相加即可,
但需要处理900, 400, 90, 40, 9, 4这几个特殊...
分类:
其他好文 时间:
2014-05-18 07:58:54
阅读次数:
293
【题目】
Given a digit string, return all possible letter combinations that the number could represent.
A mapping of digit to letters (just like on the telephone buttons) is given below.
Input:Digit string "23"
Output: ["ad", "ae", "af", "bd", "be", "bf",...
分类:
其他好文 时间:
2014-05-18 07:30:12
阅读次数:
340
【题目】
Write a function to find the longest common prefix string amongst an array of strings.
【题意】
求一组字符串的最长公共前缀
【思路】
使用归并思想求解
要求字符串[1,2,..,k,k+1,...n]的最大公共前缀,先分别求[1,2,...k]和[k+1,...,n]的公共前缀...
分类:
其他好文 时间:
2014-05-18 05:17:53
阅读次数:
232
【题目】
Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.
Note:
Elements in a triplet (a,b,c) must be in non-descending order. (ie, a ≤ b ≤ c)
The so...
分类:
其他好文 时间:
2014-05-18 03:15:50
阅读次数:
287