Longest Substring Without Repeating Characters
class Solution {public static boolean decide(char[] data1,int i,int j) {
遇到的问题:
I:查找,i,i+1;
II:验证从i+1到j和j个元素是否相等,这个过程很难直接写出来。
III:两个if-else在一起的时候,外面的else忘了
IV:字符串为空的时候没有考虑到
class Solution {public static boolean decide(char[] data1,int i,int j) {for(int k=i+1;k<j;k++) {if (data1[k]==data1[j]) return false;}return true;}public int lengthOfLongestSubstring(String s) {if(s.length()==0) return 0;else{char[] data9=s.toCharArray();int result=0;for(int i=0;i<s.length();i++) {int k=1;for(int j=i+1;j<s.length();j++) {//这个是要验证j这个元素和前面的所有的都不一样,那么才能够接纳到下一个if(s.charAt(i)!=s.charAt(j)) {if(decide(data9,i,j)) {k++;}else break;}else break;}if(result<k) result=k; }return result; }}
}
Longest Substring Without Repeating Characters相关推荐
- LeetCode.3-最长无重复字符子串(Longest Substring Without Repeating Characters)
这是悦乐书的第341次更新,第365篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Medium级别的第2题Longest Substring Without Repeating Cha ...
- 3.longest substring without repeating characters
Given a string, find the length of the longest substring without repeating characters. Example 1: In ...
- [LeetCode]3.Longest Substring Without Repeating Characters
[题目] Given a string, find the length of the longest substring without repeating characters. For exam ...
- Longest Substring Without Repeating Characters(最长不重复子序列求解)
问题描述: Given a string, find the length of the longest substring without repeating characters. Example ...
- [LeetCode] Longest Substring Without Repeating Characters
Given a string, find the length of the longest substring without repeating characters. For example, ...
- LeetCode——Longest Substring Without Repeating Characters
原问题 Given a string, find the length of the longest substring without repeating characters. Example 1 ...
- LeetCode:3. Longest Substring Without Repeating Characters
https://leetcode.com/problems/longest-substring-without-repeating-characters/description/ 内容描述: Give ...
- 【LeetCode从零单排】No 3 Longest Substring Without Repeating Characters
题目 Given a string, find the length of the longest substring without repeating characters. For exampl ...
- Leet Code OJ 3. Longest Substring Without Repeating Characters
题目 Given a string, find the length of the longest substring without repeating characters. Examples: ...
- LeetCode Longest Substring Without Repeating Characters
题意 Given a string, find the length of the longest substring without repeating characters. For exampl ...
最新文章
- 使用花生壳自己架设网站:路由器后
- 收藏:TerryLee的.NET设计模式系列文章
- 影响 PCR 体系蒸发的三大因素
- Java数据结构-基于数组的栈和泛型
- 1.0jpa 2.0_JPA 2.1如何成为新的EJB 2.0
- .net core精彩实例分享 -- 反射与Composition
- 携程ELK日志分析平台深耕之路
- Python3.x:pytesseract识别率提高(样本训练)
- Android 学习资料
- IP6K防尘试验测试
- word文档添加多个目录
- VBA--遍历所有工作表_冻结首行_无视工作表长度_and_所在单元格位置
- vhd虚拟硬盘作用_如何从VHD(虚拟硬盘)引导和安装Windows 8 Consumer Preview的指南
- 【学习笔记】欧拉函数
- win10创意者更新是什么 Win10创意者更新升级方法
- 系统集成项目管理工程师+android,系统集成项目管理工程师题库
- 前端、后端、学习网址
- 中国大学慕课——程序设计与算法(一)第三周测验
- DRV8825 TB8825 最佳线路图布局
- 思维之道:管理何必那么虚