
Implement strStr()
发布日期:2021-05-13 00:12:57
浏览次数:17
分类:精选文章
本文共 749 字,大约阅读时间需要 2 分钟。
For a given source string and a target string, you should output the first index(from 0) of target string in source string.If target does not exist in source, just return -1.
class Solution: """ @param source: @param target: @return: return the index """ def getnext(self, target): k = -1 j = 1 nexts = [-1 for i in range(len(target))] while j < len(target) - 1: if k == -1 or target[j] == target[k]: j += 1 k += 1 nexts[j] = k else: k = nexts[k] return nexts def strStr(self, source, target): # Write your code here nexts = self.getnext(target) i = 0 j = 0 while i
发表评论
最新留言
表示我来过!
[***.240.166.169]2025年04月11日 14时21分56秒
关于作者

喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
国标流媒体服务器以ROOT身份运行提示“permission denide”报错解决
2021-05-13
【视频教程】EasyNVR如何将老版本的EasyNVR的数据迁移到4.0.0以上版本
2021-05-13
qt中转到槽后如何取消信号与槽关联
2021-05-13
qt问题记录-spin box与double spin box
2021-05-13
移动端事件
2021-05-13
css 图片按比例缩放
2021-05-13
小程序form表单里面buton点击事件失效
2021-05-13
微信小程序placeholder设置自定义样式
2021-05-13
安装npm install --save vue-scroller失败
2021-05-13
spring-day01
2021-05-13
spring的值注入与组件扫描
2021-05-13
C#跨窗体程序调用方法的具体操作
2021-05-13
C#中创建Android项目
2021-05-13
C#使用OpenCV(OpenCVSharp)
2021-05-13
统计学之变异系数与是非标志
2021-05-13
统计学之偏度系数和峰度系数
2021-05-13