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)
其实如果找到前缀任务就完成了
思维题
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)
其实如果找到前缀任务就完成了
思维题