Practice Minimum Time to Revert Word to Initial State I
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Medium#3029
LeetCode ProblemMinimum Time to Revert Word to Initial State I
Problem Statement
Given word and k, perform one operation per second: remove its first k characters and append any k characters to its end. The appended characters need not match those removed. Return the smallest positive number of seconds after which the word can equal its initial value.
Source: Minimum Time to Revert Word to Initial State I on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
word = "abacaba", k = 3
Output
2
# Example 2
Input
word = "abacaba", k = 4
Output
1
# Example 3
Input
word = "abcbabcd", k = 2
Output
4
Constraints
1 <= word.length <= 50
1 <= k <= word.length
word consists only of lowercase English letters.
Related LeetCode Problems
Practice more problems similar to Minimum Time to Revert Word to Initial State I.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.