码迷,mamicode.com
首页 > 其他好文 > 详细

#3 Longest substring without repeating characters

时间:2018-11-10 15:04:19      阅读:189      评论:0      收藏:0      [点我收藏+]

标签:until   eating   ret   ide   ati   oop   hashset   int   size   

  1. Sliding window

  2. Hashset

  3. Loop through every element inside the string. If the current char is not inside the hashset, push the char into the hashset and update the longest value. If the current char is already inside the hashset, change the left boundary of the sliding window until the current char is not inside the hashset.

  4. Return the longest value.

  5. Time complexity: O(n). Space complexity: O(the size of the hashset)

#3 Longest substring without repeating characters

标签:until   eating   ret   ide   ati   oop   hashset   int   size   

原文地址:https://www.cnblogs.com/yxcindy/p/9938770.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!