<2017年6月>
28293031123
45678910
11121314151617
18192021222324
2526272829301
2345678

统计

  • 随笔 - 57
  • 文章 - 7
  • 评论 - 0
  • 引用 - 0

常用链接

留言簿

随笔分类

随笔档案

文章分类

文章档案

Blog

Coder 必备技巧

Compiler for Wurq

搜索

  •  

最新评论

阅读排行榜

评论排行榜

【LeeCode 2017/06/18】 3. Longest Substring Without Repeating Characters
 1 class Solution {
 2 public:
 3     int lengthOfLongestSubstring(string s) {
 4         int mark[256= { 0 };
 5         int begin = 0;
 6         int end = 0;
 7         int ret_max = 0;
 8         while (begin<=end &&begin <s.length() && end<s.length())
 9         {
10             char ch = s[end];
11             if (mark[ch] == 0){
12                 mark[ch]++;
13                 end++;
14             }else{
15                 ch = s[begin];
16                 mark[ch]--;
17                 begin++;
18             }
19             ret_max = end - begin > ret_max ? end - begin : ret_max;
20         }
21         return ret_max;
22     }
23 };
24 

posted on 2017-06-16 09:34 Wurq 阅读(74) 评论(0)  编辑 收藏 引用 所属分类: 【LeeCode 每日N题】


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理