文件名称:
README.md
所在目录:
教材与参考资料 / 程序设计类 / 数据结构&算法 / 算法 / 面试与力扣题目详解 / Leetcode题目和解答 / java-leetcode / longest-substring-without-repeating-characters
文件大小:
378.00 B
下载地址:
文本预览:
## Loop invariant
Set a `barrier`, such that, `s[barrier..current]` contains no repeating characters.
when a new char comes, update the `barrier` if needed.
the `current - barrier + 1` is the length of the substring.
```
barrier = 0
foreach i in s
while s[barrier .. i] contains characters
barrier = barrier + 1
max = MAX(max, current - barrier + 1)
```
Set a `barrier`, such that, `s[barrier..current]` contains no repeating characters.
when a new char comes, update the `barrier` if needed.
the `current - barrier + 1` is the length of the substring.
```
barrier = 0
foreach i in s
while s[barrier .. i] contains characters
barrier = barrier + 1
max = MAX(max, current - barrier + 1)
```
点赞
回复
X