思路:类似双指针,用left标定以当前字母结尾的最长无重的substring的起点。逐个扫描字母,如果这个字母当前的substring里面没有,那么当前的substring长度就可以加一。如果这个字母已经在substring里面了,例如: 当扫描到第二个c的时候,left应该移到d上来。并且应该将 ...
分类:
其他好文 时间:
2017-01-24 13:36:07
阅读次数:
195
这类问题可以先用递归思考,再反过来想出动态规划的方法。 10. Regular Expression Matching 32. Longest Valid Parentheses 44. Wildcard Matching 72. Edit Distance 97. Interleaving Str ...
分类:
其他好文 时间:
2017-01-22 13:51:20
阅读次数:
210
Write a SQL query to find all numbers that appear at least three times consecutively. For example, given the above Logs table, 1 is the only number th ...
分类:
数据库 时间:
2017-01-21 07:44:30
阅读次数:
249
倒序查看,不包含jiuzhang ladders中出现过的题。 1 Longest Substring Without Repeating Characters not bug free 给一个字符串,找出其中不包含重复字符的最长子串的长度。 Examples: Given "abcabcbb", ...
分类:
其他好文 时间:
2017-01-20 16:08:00
阅读次数:
200
Given a binary array, find the maximum number of consecutive 1s in this array. ...
分类:
其他好文 时间:
2017-01-20 12:31:10
阅读次数:
168
A sequence of number is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the ... ...
分类:
编程语言 时间:
2017-01-19 02:51:14
阅读次数:
249
Given a binary array, find the maximum number of consecutive 1s in this array. Example 1: Note: The input array will only contain 0 and 1. The length ...
分类:
其他好文 时间:
2017-01-17 07:50:43
阅读次数:
229
Given a binary array, find the maximum number of consecutive 1s in this array.Example 1:Input: [1,1,0,1,1,1] Output: 3 Explanation: The first two digi... ...
分类:
其他好文 时间:
2017-01-15 17:59:10
阅读次数:
814
Find the length of the longest substring T of a given string (consists of lowercase letters only) such that every character in T appears no less than ...
题目要求求出长度即可,并不需要求出最长回文串。思路:用字典统计每一个字符的出现次数,出现次数大于1的字符必定出现在回文串中,另外还再加上一个中心点。public static int LongestPalindrome(string s) { int length = 0; Dictionary d... ...
分类:
其他好文 时间:
2017-01-10 23:40:59
阅读次数:
230