2014年(53)
发布时间:2014-10-07 15:06:53
Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring.首先我用了DP,没想到存储没报错,时间报错了,TLE了。原理是记录所有回文,然后更新最大值。比较值得注意.........【阅读全文】
发布时间:2014-10-07 14:55:35
Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.For "(()", the longest valid parentheses substring is "()", which has length = 2..........【阅读全文】
发布时间:2014-10-07 14:38:42
Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).For example,S = "ADOBECODEBANC"T = "ABC"Minimum window is "BANC"..........【阅读全文】
发布时间:2014-10-07 14:29:36
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:.........【阅读全文】
发布时间:2014-10-07 14:23:17
Divide two integers without using multiplication, division and mod operator.整数的除法,但无法用乘号,除号和余号。可以考虑二分,假设A/B, 则解空间在[0, A]当B*A/2<A时,表明解在[A/2,A]之间==>注意这里A/2可能是解,因为整数的除法是舍去余数的当B*A/2>A时,表明解在[0, A/2)之间,当B*A/2==A时,表明解.........【阅读全文】