算法描述: Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. Example 1: Examp ...
分类:
其他好文 时间:
2019-02-01 14:12:17
阅读次数:
161
算法描述: Given an array of strings, group anagrams together. Example: Note: All inputs will be in lowercase. The order of your output does not matter. 解题 ...
分类:
其他好文 时间:
2019-01-29 20:47:18
阅读次数:
200
In a string S of lowercase letters, these letters form consecutive groups of the same character. For example, a string like S = "abbxxxxzyy" has the g ...
分类:
其他好文 时间:
2019-01-28 23:07:06
阅读次数:
176
Let's consider m apples divided into n groups. Each group contains no more than 100 apples, arranged in a line. You can take any number of consecutive ...
3. Longest Substring Without Repeating Characters 1)题目 2)思路 先写一个子函数,输入数组下标,母字符串,往后遍历,获得下标出最长子串长度。 遍历母字符串,调用子函数,获得每一位长度,放入数组里。 获取数组最大值。 3) 代码 public in ...
分类:
其他好文 时间:
2019-01-28 00:58:44
阅读次数:
200
5. Longest Palindromic Substring 1)题目 2)思路 遍历s, 判断每一位为中间位的最大回文子串。 比较即可。 3) 代码 4) 结果 时间复杂度:O(n^2) 空间复杂度:O(n) 耗时: 5) 调优 ...
分类:
其他好文 时间:
2019-01-28 00:56:12
阅读次数:
144
这题要求两个串中的最长相同子串的长度。高度数组可以求一个串中的最长相同子串的长度。所以想到把两个串连起来,但是这样又会产生一些新的串(第一个串的结尾和第二个串的开头组成的)于是在两个串中间放一个'\0'分隔,正好'\0'是字符里最小的,不会对第一个串的排序产生影响。 ...
分类:
编程语言 时间:
2019-01-27 16:39:03
阅读次数:
187
Write a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty string "". Exampl ...
分类:
其他好文 时间:
2019-01-26 22:04:03
阅读次数:
171
Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. Example 1: Example 2: 还是用DP来递归,抓住回 ...
分类:
其他好文 时间:
2019-01-26 21:38:37
阅读次数:
150
[toc] 题目链接 "Longest Common Prefix LeetCode" 注意点 考虑输入的字符串没有和只有一个的情况。 解法 解法一:先比较两个字符串得到他们的最长相同前缀,这就是答案就会是其他字符串和这个最长相同前缀的最长相同前缀。时间复杂度为O(nm) class Solutio ...
分类:
其他好文 时间:
2019-01-26 15:27:24
阅读次数:
211