3 Longest Substring Without Repeating Characters
public int lengthOfLongestSubstring(String s) { long length = s.length(); String tmp = ""; int substringLength = 0; for (int i = 0; i < length; i ++) { if (tmp.contains(("" + s.charAt(i)))) { if (tmp.length() > substringLength) substringLength = tmp.length(); int idx = tmp.indexOf(s.charAt(i) + ""); tmp = tmp.substring(idx + 1) + s.charAt(i); } else { tmp = tmp + s.charAt(i); if (substringLength < tmp.length()) substringLength = tmp.length(); } } return substringLength; }
3 Longest Substring Without Repeating Characters的更多相关文章
- LeetCode[3] Longest Substring Without Repeating Characters
题目描述 Given a string, find the length of the longest substring without repeating characters. For exam ...
- [LeetCode] Longest Substring Without Repeating Characters 最长无重复子串
Given a string, find the length of the longest substring without repeating characters. For example, ...
- Longest Substring Without Repeating Characters
Given a string, find the length of the longest substring without repeating characters. Examples: Giv ...
- 3. Longest Substring Without Repeating Characters(c++) 15ms
Given a string, find the length of the longest substring without repeating characters. Examples: Giv ...
- 【leetcode】Longest Substring Without Repeating Characters
题目描述: Given a string, find the length of the longest substring without repeating characters. For exa ...
- Longest Substring Without Repeating Characters(C语言实现)
Given a string, find the length of the longest substring without repeating characters. Examples: Giv ...
- leetcode: longest substring without repeating characters
July 16, 2015 Problem statement: Longest Substring Without Repeating Characters Read the blog: http: ...
- [LeetCode_3] Longest Substring Without Repeating Characters
LeetCode: 3. Longest Substring Without Repeating Characters class Solution { public: int lengthOfLon ...
- Longest Substring Without Repeating Characters (c#)
Given a string, find the length of the longest substring without repeating characters. For example, ...
- Longest Substring Without Repeating Characters(Difficulty: Medium)
题目: Given a string, find the length of the longest substring without repeating characters. Examples: ...
随机推荐
- C++设计模式-Adapter适配器模式
Adapter适配器模式作用:将一个类的接口转换成客户希望的另外一个接口.Adapter模式使得原本由于接口不兼容而不能一起工作的那些类可以一起工作. 分为类适配器模式和对象适配器模式. 系统的数据和 ...
- JavaScript能干什么?
真的是长见识了,JavaScript居然能做除了WEB界面外运行于任何平台的APP,而且可以做服务器端,还有天理和王法吗?JavaScript到底有多神奇,要不要重新上路,老程序员何去何从,自然要先网 ...
- javascript this关键字指向详解
在之前写代码的经历中,常常试过写着写着this就莫名其妙的不知道指向到哪里去了.今天看了曾探的javascript设计模式,里面特别谈到了this在不同情况下指代的对象,非常有意思. this指代的情 ...
- 欧冠杯:葡萄牙VS法国——葡萄牙首次夺冠!
北京时间7月11日凌晨3点,2016欧洲杯决赛,葡萄牙在法兰西大球场1-0击败东道主法国,历史上首次夺冠.C罗伤退落泪,替补出场的埃德尔在加时赛第109分钟完成绝杀. 昨晚上本来准备熬夜看球赛的!而且 ...
- VMware中装Win2012并配置Hyper-v
VMware中装配Win2012再配置Hyper-v,解决虚拟机监控程序已经在运行中的方法 找到虚拟机存放的位置,用记事本打开Windows Server 2012.vmx,在最后添加两行并保存: h ...
- arcgis将图片转成shp地图
打开arcMap 1.右键[图层]-[属性]-[坐标系]-[地理坐标系]-双击"WGS 1984" 2.右键[图层]-[添加数据],打开图片文件-Band_2 3.右键图片-[属性 ...
- publish/subscribe
Pub/Sub功能 Pub/Sub功能(means Publish, Subscribe)即发布及订阅功能.基于事件的系统中,Pub/Sub是目前广泛使用的通信模型,它采用事件作为基本的通信机制,提供 ...
- Js获取图片原始宽高
如果我们页面看到的图片都是缩略图,那就需要做个图片点击放大效果,那么怎样获取图片的原始宽高呢?方法如下: //获取图片原始宽度 function getNaturalWidthAndHeight(im ...
- Mysql技术内幕(第四版)读书笔记(一)
题记:写代码已经有2年了,学到了很多知识,但是没有一个好习惯去记录,去分享,好多知识点都会忘记,所以从今天开始学着像大牛一样去记录自己经历项目的点点滴滴,先从最近读<Mysql技术内幕>开 ...
- LSTM 分类器笔记及Theano实现
相关讨论 http://tieba.baidu.com/p/3960350008 基于教程http://deeplearning.net/tutorial/lstm.html LSTM基本原理http ...