0
点赞
收藏
分享

微信扫一扫

3031. Minimum Time to Revert Word to Initial State II

源码之路 2024-02-08 阅读 9
leetcode

3031. Minimum Time to Revert Word to Initial State II

class Solution:
    def minimumTimeToInitialState(self, word: str, k: int) -> int:
        for i in range(k,len(word),k):
            if word.startswith(word[i:]):return int(i/k)
        return ceil(len(word)/k)

其实如果找到前缀任务就完成了

思维题

举报

相关推荐

0 条评论