leetcode: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" is "abc", which the length is 3. For "bbbbb" the longest substring is "b", with the length of 1.
解决方法(java版)
class Solution{
public int lengthOfLongestSubstring(String s) {
String str=new String();
str="";
int max=0;
for(int i=0;i<s.length();i++){
for(int j=i;j<s.length();j++){
if(str.contains(String.valueOf(s.charAt(j)))){
break;
}
else{
str+=s.charAt(j);
}
}
if(str.length()>max)
max=str.length();
str="";
}
return max;
}
}
leetcode:Longest Substring Without Repeating Characters的更多相关文章
- C++版- Leetcode 3. Longest Substring Without Repeating Characters解题报告
Leetcode 3. Longest Substring Without Repeating Characters 提交网址: https://leetcode.com/problems/longe ...
- Leetcode经典试题:Longest Substring Without Repeating Characters解析
题目如下: Given a string, find the length of the longest substring without repeating characters. Example ...
- LeetCode OJ:Longest Substring Without Repeating Characters(最长无重复字符子串)
Given a string, find the length of the longest substring without repeating characters. For example, ...
- LeetCode第[3]题(Java):Longest Substring Without Repeating Characters 标签:Linked List
题目中文:没有重复字符的最长子串 题目难度:Medium 题目内容: Given a string, find the length of the longest substring without ...
- leetcode笔记:Longest Substring Without Repeating Characters
一. 题目描写叙述 Given a string, find the length of the longest substring without repeating characters. For ...
- No.003:Longest Substring Without Repeating Characters
问题: Given a string, find the length of the longest substring without repeating characters.Example:Gi ...
- LeetCode 3 Longest Substring Without Repeating Characters(最长不重复子序列)
题目来源:https://leetcode.com/problems/longest-substring-without-repeating-characters/ Given a string, f ...
- LeetCode 3 Longest Substring Without Repeating Characters 解题报告
LeetCode 第3题3 Longest Substring Without Repeating Characters 首先我们看题目要求: Given a string, find the len ...
- Leetcode 3. Longest Substring Without Repeating Characters (Medium)
Description Given a string, find the length of the longest substring without repeating characters. E ...
随机推荐
- javascript whenReady
var whenReady=(function(){ var funcs=[]; var ready=false; function handler(e){ if (ready) { return; ...
- hihoCoder 1043 完全背包 (dp)
http://hihocoder.com/problemset/problem/1043 动态转移方程 :for v=cost..V f[v]=max(f[v],f[v-c[i]]+w[i]); #i ...
- Android 工程在4.0基础上混淆
Android现在对安全方面要求比较高了,我今天要做的对apk进行混淆,用所有的第三方工具都不能反编译,作者的知识产权得到保障了,是不是碉堡了. 一,首先说明我这是在4.0基础上进行的. 先看看pro ...
- How to use 'crontab' command on bitnami
You can edit the cron file using the following command: $ sudo crontab -e You can add a new line lik ...
- 【Scala学习笔记】第01弹——Scala安装与配置
安装Scala之前先要安装JDK(1.5以上),最好安装JDK 1.8+,安装好JDK后配置JDK的环境变量. 然后去Scala官网(http://www.scala-lang.org/downloa ...
- AWS 之Load Balance篇
public class CreateELB { /// <summary> /// 连接AWS服务器 /// </summary> /// <param name=&q ...
- HDU 1728 逃离迷宫【BFS】
题意:给出一个起点,一个终点,规定的转弯次数,问能否在规定的转弯次数内到达终点--- 这一题是学(看)习(题)的(解)@_@ 主要学了两个地方 一个是剪枝,如果搜到的当前点的转弯次数小于该点turn数 ...
- [xUnix 开发环境--01] MAMP mac os 10.10 配置经历、要点——01. phpmyadmin连不上
Mac OS 10.10已经自带了apache2和php(php的路径我至今还没不知道,太懒没去找) 用brew安装mysql, 在官网上下载了phpmyadmin,按官方方式配置完后,登录不上,也不 ...
- python执行mysqldump命令
本文简单讲述如何利用python执行一些sql语句,例如执行mysqldump命令,进行数据库备份,备份成sql文件 #!/usr/bin/python#导入os模块import os#导入时间模块i ...
- linux中备份mysql数据库的一个shell脚本
#!/bin/bash #FileName:select_into_bak.sh #Desc:Use select into outfile to backup db or tables #Creat ...