3137. Minimum Number of Operations to Make Word K-Periodic
You are given a string
wordof sizen, and an integerksuch thatkdividesn.In one operation, you can pick any two indices
iandj, that are divisible byk, then replace the substring of lengthkstarting atiwith the substring of lengthkstarting atj. That is, replace the substringword[i..i + k - 1]with the substringword[j..j + k - 1].Return the minimum number of operations required to make
wordk-periodic.We say that
wordis k-periodic if there is some stringsof lengthksuch thatwordcan be obtained by concatenatingsan arbitrary number of times. For example, ifword == “ababab”, thenwordis 2-periodic fors = "ab".