CodeTop100
无重复字符的最长子串 (双指针法 + 哈希)题目描述:给定一个字符串 s ,请你找出其中不含有重复字符的最长子串的长度。123456789101112131415161718class Solution: def lengthOfLongestSubstring(self, s: str) -> int: # 哈希集合, 记录每个字符是否出现过 occ = set() n = len(s) # 右指针,初始值为 -1, 相当于我们在字符串的左边界的左侧,还没有开始移动 rk, ans = -1, 0 for i in range(n): if i != 0: # 左指针向右移动一格,移动一个字符 occ.remove(s[i - 1]) while rk + 1 < n and s[rk + 1] not in occ: # 不断地移动右指针 ...
深圳大学
深圳大学 基本信息 英文名:Shenzhen University (SZU) 成立时间:1983年 校训:自立、自律、自强 地址:广东省深圳市南山区南海大道3688号 官网:www.szu.edu.cn 校园风光 “海压竹枝低复举,风吹山脚晦还明!”—— 持续更新中 ——
美好回忆
收集生活中那些值得珍藏的瞬间… 📸 旅行时光 “回忆是时光的礼物,让平凡的日子闪闪发光”—— 持续更新中 ——
Hello World
Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub. Quick StartCreate a new post1$ hexo new "My New Post" More info: Writing Run server1$ hexo server More info: Server Generate static files1$ hexo generate More info: Generating Deploy to remote sites1$ hexo deploy More info: Deployment