Description: Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. For "bbbbb" the…
题目链接:https://leetcode.com/problems/longest-substring-without-repeating-characters/ 题目:Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb&qu…
[题意] Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. For "bbbbb" the longest…
题目描述: Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. For "bbbbb" the longest…
Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. For "bbbbb" the longest subst…
题目: Given a string, find the length of the longest substring without repeating characters. Example 1: Input: "abcabcbb" Output: 3 Explanation: The answer is "abc", with the length of 3. Example 2: Input: "bbbbb" Output: 1 Exp…
Given a string, find the length of the longest substring without repeating characters. Example 1:           Input: "abcabcbb"                              Output: 3                           Explanation: The answer is "abc", with the l…
Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. For "bbbbb" the longest subst…
Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. For "bbbbb" the longest subst…
题目: Given a string, find the length of the longest substring without repeating characters. Examples: Given "abcabcbb", the answer is "abc", which the length is 3. Given "bbbbb", the answer is "b", with the length of…
我现在在做一个叫<leetbook>的免费开源书项目,力求提供最易懂的中文思路,目前把解题思路都同步更新到gitbook上了,需要的同学可以去看看 书的地址:https://hk029.gitbooks.io/leetbook/ 003. Longest Substring Without Repeating Characters[M] Longest Substring Without Repeating CharactersM 题目 思路 代码 题目 Given a string, fin…
Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. For "bbbbb" the longest subst…
一. 题目描写叙述 Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. For "bbbbb" the lon…
这道题是LeetCode里的第3道题. 题目描述: 给定一个字符串,请你找出其中不含有重复字符的 最长子串 的长度. 示例 1: 输入: "abcabcbb" 输出: 3 解释: 因为无重复字符的最长子串是 "abc",所以其长度为 3. 示例 2: 输入: "bbbbb" 输出: 1 解释: 因为无重复字符的最长子串是 "b",所以其长度为 1. 示例 3: 输入: "pwwkew" 输出: 3 解释:…
题目链接:https://leetcode.com/problems/longest-palindromic-substring/ 题目: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. 解题思路:p…
题目描述: 解题思路: 借用网上大神的思想:the basic idea is, keep a hashmap which stores the characters in string as keys and their positions as values, and keep two pointers which define the max substring. move the right pointer to scan through the string , and meanwhi…
Problem Link: http://oj.leetcode.com/problems/longest-consecutive-sequence/ This problem is a classical problem where we can reduce the running time by the help of hash table. By given a list of numbers, we can find the longest consecutive sequence b…
Longest Valid Parentheses 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…
题目链接:https://leetcode.com/problems/longest-substring-without-repeating-characters/description/ 题目要求:求出最长的不重复子串 思路: 1.采用map,遍历字符串,将每个字符put进map2.如果长度为1,直接输出13.end-begin+1(注意+1) end为当前遍历到的位置, begin为重复位置+1 4.在遍历字符串的时候,判断当前字符是否存在resultMap.containsKey(key)…
思路:看到题目首先想到最大字符串匹配KMP算法 public static int lengthOfLongestSubstring(String s) { int maxLength = 0; StringBuilder sb = new StringBuilder(s); a:for(int i = 0;i<sb.length();i++){ StringBuilder sb2 = new StringBuilder(""); sb2.append(sb.substring(…
这题的题意大概就是给你一个字符串"abcdecde",找到最长的子字符串长度,里面所有的子母都不重复.本例子中最长的满足条件的子字符串就是"abcde",所以应该返回的是5.这一题如果不用暴力解决的方法的话,我优先想到的数据结构是HashMap,因为它能够判断字母是否重复,并且记录每个字母的index.而现在唯一的难点就是,怎么通过HashMap来找到这个最长字符串.因为要记录子字符串的长度,从而,肯定需要两个index,一个index1作为子字符串的头,另一个in…
题目描述:求一个字符串的不含重复字符的最长连续子串的长度: 思路: 使用一个哈希表保存字符出现的位置: 使用left和right分别表示子串的最左和最右字符的下标: 遍历字符串,如果当前字符在哈希表中并且当前字符在哈希中的位置大于left,表明left和right之间存在和right索引上相同的字符,此时把left置为当前值在哈希表中的值: 把当前索引值+1,表示是第几个字符,求出当前最大长度: 3-4步重复,直到获得遍历完成: 感觉这是个动态规划题,暂时没用动态规划分析,后续再说. class…
[Q1] Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution, and you may not use the same element twice. Example: Given nums = [2, 7, 11…
一天一道LeetCode (一)题目 Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. For "bbbbb"…
题目等级:Medium 题目描述:   Given a string, find the length of the longest substring without repeating characters.   Example 1: Input: "abcabcbb" Output: 3 Explanation: The answer is "abc", with the length of 3.   Example 2: Input: "bbbbb…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 公众号:负雪明烛 本文关键词:无重复字符,最长子串,题解,leetcode, 力扣,python, c++, java 目录 题目描述 题目大意 解题方法 解法一:虫取法+set 方法二:一次遍历+字典 日期 题目地址:https://leetcode.com/problems/longest-substring-without-repeating-characters/descrip…
Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. For "bbbbb" the longest subst…
题目: Given a string, find the length of the longest substring without repeating characters. Examples: Given "abcabcbb", the answer is "abc", which the length is 3. Given "bbbbb", the answer is "b", with the length of…
题目 Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. For "bbbbb" the longest su…
Given a string, find the length of the longest substring without repeating characters. Examples: Given "abcabcbb", the answer is "abc", which the length is 3. Given "bbbbb", the answer is "b", with the length of 1.…