算法分析与设计第十九周: 567. Permutation in String
来源:互联网 发布:哪里可以买到淘宝小号 编辑:程序博客网 时间:2024/09/21 08:15
class Solution(object): def checkInclusion(self, s1, s2): l1 = [0 for _ in range(26)] l2 = [0 for _ in range(26)] size1 = len(s1) size2 = len(s2) if size2 < size1: return False if size1 == 0: return True charSet = set() for c in s1: l1[ord(c) - ord('a')] += 1 charSet.add(ord(c) - ord('a')) for i in range(size1): l2[ord(s2[i]) - ord('a')] += 1 hasFound = True for c in charSet: if l1[c] != l2[c]: hasFound = False if hasFound: return True i = size1 while i < size2: l2[ord(s2[i - size1]) - ord('a')] -= 1 l2[ord(s2[i]) - ord('a')] += 1 hasFound = True for c in charSet: if l1[c] != l2[c]: hasFound = False if hasFound: return True i += 1 return False
阅读全文
0 0
- 算法分析与设计第十九周: 567. Permutation in String
- 第八周算法分析与设计:Permutation Sequence
- 567. Permutation in String
- 567. Permutation in String
- 567. Permutation in String
- 567. Permutation in String
- [leetcode]567. Permutation in String
- 567. Permutation in String Medium
- [leetcode] 567. Permutation in String
- 【LeetCode】567. Permutation in String
- [LeetCode] 567. Permutation in String
- Leetcode 567. Permutation in String
- 算法分析与设计课程11——467. Unique Substrings in Wraparound String(Medium)
- [算法分析与设计] leetcode 每周一题: 467. Unique Substrings in Wraparound String
- 567. Permutation in String 字符串置换
- leetcode 567. Permutation in String 滑动窗口
- [Leetcode] 567. Permutation in String 解题报告
- Permutation in String
- Gitlab 隐藏注册功能
- 浅谈CSS属性之布局--flex布局<弹性盒模型>
- asp.net core 绑定CheckBoxList
- Java抽象工厂模式
- android Textview过长时显示省略号
- 算法分析与设计第十九周: 567. Permutation in String
- linux下调用opencv接口函数,在一张图片上面画框
- 《Linux内核完全剖析》读书笔记(待续...)
- 一些基础的高效编程方法
- 压力传感器HX711的C函数
- 嵌入式QT基础视频教程免费分享!
- Javascript异步编程的4种方法
- win7滑轮滚动excel就停止工作的解决方法
- office 系列产品 -- visio 2013 / project 2013 破解工具