Categorygithub.com/szhou12/leetcode-goleetcode3137-Minimum-Number-of-Operations-to-Make-Word-K-Periodic
package
0.0.0-20241220224003-b7cf03a90b2b
Repository: https://github.com/szhou12/leetcode-go.git
Documentation: pkg.go.dev

# README

3137. Minimum Number of Operations to Make Word K-Periodic

Solution idea

  1. Any indices i, j to pick are divisible by k. In other words, i, j are multiples of k. Every substring has fixed length k. Thus, we use a map to record each substring of length k and its frequency. Find the substring of the highest frequency m. The minimum number of operations = n/k - m.

Time complexity = $O(n)$