LeetCode题解(1078):Bigram分词(Python)
发布日期:2021-06-29 19:55:22 浏览次数:2 分类:技术文章

本文共 435 字,大约阅读时间需要 1 分钟。

题目:(简单)

解法 时间复杂度 空间复杂度 执行用时
Ans 1 (Python) O ( N ) O(N) O(N) O ( N ) O(N) O(N) 40ms (60.29%)
Ans 2 (Python)
Ans 3 (Python)

LeetCode的Python执行用时随缘,只要时间复杂度没有明显差异,执行用时一般都在同一个量级,仅作参考意义。

解法一:

def findOcurrences(self, text: str, first: str, second: str) -> List[str]:    text = text.split(" ")    ans = []    for i in range(len(text) - 2):        if text[i] == first and text[i + 1] == second:            ans.append(text[i + 2])    return ans

转载地址:https://dataartist.blog.csdn.net/article/details/107104916 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:LeetCode题解(1089):复写列表中的零(Python)
下一篇:LeetCode题解(1071):字符串的最大公因子(Python)

发表评论

最新留言

很好
[***.229.124.182]2024年04月19日 01时53分13秒