1 var lengthOfLongestSubstring = function(s) { 2 if (s === '') { 3 return 0; 4 } 5 6 var lenMax = 1, 7 lenCurr = 1, 8 ...
分类:
其他好文 时间:
2015-11-22 00:19:16
阅读次数:
121
思路:每次从字符数组中读取两个字符串比较。需要注意输入字符串为空,等细节。 1 public String longestCommonPrefix(String[] strs) { 2 if(strs==null||strs.length==0){ 3 ...
分类:
其他好文 时间:
2015-11-20 18:57:17
阅读次数:
131
class Solution(object): def longestCommonPrefix(self, strs): """ :type strs: List[str] :rtype: str """ if len(st...
分类:
编程语言 时间:
2015-11-19 20:55:53
阅读次数:
249
贴个代码...---------------------------------------------------------------------#include#include#includeusing namespace std;const int maxn = 200009;const ...
分类:
其他好文 时间:
2015-11-17 23:23:04
阅读次数:
236
题目描述:(链接)Given a string containing just the characters'('and')', find the length of the longest valid (well-formed) parentheses substring.For"(()", th...
分类:
其他好文 时间:
2015-11-17 18:47:05
阅读次数:
142
题意: 给一个数组,求严格递增的最长递增子序列的长度。思路: 开销是一个额外的O(n)的数组。lower_bound(begin,end,val)的功能是:返回第一个大于等于val的地址。 1 class Solution { 2 public: 3 int lengthOfLIS(ve...
分类:
其他好文 时间:
2015-11-16 22:38:20
阅读次数:
174
1. TitleLongest Palindromic Substring2. Http addresshttps://leetcode.com/problems/longest-palindromic-substring/3. The questionGiven a stringS, find t...
分类:
其他好文 时间:
2015-11-16 22:22:59
阅读次数:
240
uva 221提供个房子的坐标以及房子宽度和高度,要求你求从南边看过去,可以看到的房子有哪些PS:一定要注意题目的这句:One blank line must separate output from consecutive input records.不然会直接报错可以直接使用暴力做,不过要注意枚...
分类:
其他好文 时间:
2015-11-16 17:35:48
阅读次数:
139
DFS + Memorized Search (DP)class Solution { int dfs(int i, int j, int row, int col, vector>& A, vector>& dp) { if(dp[i][j] != 0) retu...
分类:
其他好文 时间:
2015-11-16 06:09:19
阅读次数:
287
Longest Increasing SubsequenceGiven an unsorted array of integers, find the length of longest increasing subsequence.For example,Given[10, 9, 2, 5, 3,...
分类:
编程语言 时间:
2015-11-15 20:29:16
阅读次数:
482