Tap here to switch tabs
Problem
Submissions

Problem: Minimum Time to Revert Word to Initial State II

Minimum Time to Revert Word to Initial State II gives a string and k, then asks for the first positive time when removing k leading characters and appending arbitrary letters restores original string.

Statement

You are given a 00 indexed string word and an integer k.

At every second, you must remove the first k characters of word and append any k lowercase English letters to the end of word.

Return the minimum time greater than 00 required for word to revert to its initial state.

Note: The characters appended at each step can be chosen arbitrarily and do not need to match the removed characters.

Constraints:

  • 1≤1 \leq word.length ≤106\leq 10^6

  • 1≤1 \leq k ≤\leq word.length

  • word consists only of lowercase English letters.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Time to Revert Word to Initial State II

Minimum Time to Revert Word to Initial State II gives a string and k, then asks for the first positive time when removing k leading characters and appending arbitrary letters restores original string.

Statement

You are given a 00 indexed string word and an integer k.

At every second, you must remove the first k characters of word and append any k lowercase English letters to the end of word.

Return the minimum time greater than 00 required for word to revert to its initial state.

Note: The characters appended at each step can be chosen arbitrarily and do not need to match the removed characters.

Constraints:

  • 1≤1 \leq word.length ≤106\leq 10^6

  • 1≤1 \leq k ≤\leq word.length

  • word consists only of lowercase English letters.