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: ...
随机推荐
- ARCGIS如何进行可视域分析
可视域分析在不同的领域有着广泛的应用,如火灾监控点的设定,观察哨所的设定等等.军事领域是可视域分析技术应用最广的领域.例如为了设计巡航导弹的航线,就必须对发射点到目标的地形进行分析,包括地形特征优劣分 ...
- c++ Primer 第四版 第一阶段 const总结
由于期末值考一门软件安全,所以果断看起c++Primer ,因为之前看谭浩强的c++感觉没什么用啊.所以这本书每阶段做个总结!!! 1.Const限定符作用: 在for循环中上限应该用一个固定变量来设 ...
- HTML。CSS浮动元素详解
浮动定位是指 1.1将元素排除在普通流之外,即元素将脱离标准文档流 1.2元素将不在页面占用空间 1.3将浮动元素放置在包含框的左边或者右边 1.4浮动元素依旧位于包含框之内 2. 浮动的框可以向左或 ...
- Jquery.cookie.js 源码和使用方法
jquery.cookie.js源码和使用方法 jQuery操作cookie的插件,大概的使用方法如下 $.cookie(‘the_cookie’); //读取Cookie值$.cookie(’the ...
- 用CMake构建Qt5的Visual Studio工程
使用Visual Studio构建Qt工程的方法有很多种,可以使用Visual Studio自带的功能手动创建配置工程,也可以创建pro文件,然后通过VS的Qt插件导入进行创建.还有一种方式是通过CM ...
- Python描述符(descriptor)解密(转)
原文:http://www.geekfan.net/7862/ Python中包含了许多内建的语言特性,它们使得代码简洁且易于理解.这些特性包括列表/集合/字典推导式,属性(property).以及装 ...
- XML语法
xml文档内容如下:(必须全英文输入,空格都要是英文的!) 1.文档声明 2.元素 3.属性 4.注释 5.CDATA区.特殊字符 6.处理指令 <?xml version="1.0& ...
- KBMMW 4.93.10 发布
例行更新,主要是bugfix. 4.93.10 June 4 2016 Important notes (changes that may break existing code) ========= ...
- Md5 签名算法
/// <summary> /// MD5签名 /// </summary> /// <param name="pre ...
- Android之官方下拉刷新控件SwipeRefreshLayout
SwipeRefreshLayout 是在V4包里面,首先要先导入V4包,最新的V4包里面才有这控件 首先是布局 <android.support.v4.widget.SwipeRefreshL ...