博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Longest Substring Without Repeating Characters
阅读量:4074 次
发布时间:2019-05-25

本文共 777 字,大约阅读时间需要 2 分钟。

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代码:

public class Solution {    public int lengthOfLongestSubstring(String s) {         if(s.length()==0) return 0;        if(s.length()==1) return 1;        int length=0;        String part=""+s.charAt(0);        for(int i=1;i
length) { length=part.length(); } part=part.substring(index+1); i--; } } return part.length()>length?part.length():length; }}

转载地址:http://vnuni.baihongyu.com/

你可能感兴趣的文章
如何自定义iOS中的控件
查看>>
iOS 开发百问
查看>>
Mac环境下svn的使用
查看>>
github简单使用教程
查看>>
如何高效利用GitHub
查看>>
环境分支-git版本管理
查看>>
uni-app 全局变量
查看>>
java 不用递归写tree
查看>>
springboot2 集成Hibernate JPA 用 声明式事物
查看>>
fhs-framework jetcache 缓存维护之自动清除缓存
查看>>
SpringBoot 动态编译 JAVA class 解决 jar in jar 的依赖问题
查看>>
fhs-framework springboot mybatis 解决表关联查询问题的关键方案-翻译服务
查看>>
ZUUL2 使用场景
查看>>
Spring AOP + Redis + 注解实现redis 分布式锁
查看>>
支付宝生活号服务号 用户信息获取 oauth2 登录对接 springboot java
查看>>
CodeForces #196(Div. 2) 337D Book of Evil (树形dp)
查看>>
uva 12260 - Free Goodies (dp,贪心 | 好题)
查看>>
uva-1427 Parade (单调队列优化dp)
查看>>
【设计模式】学习笔记14:状态模式(State)
查看>>
poj 1976 A Mini Locomotive (dp 二维01背包)
查看>>