Problem Statement | |||||||||||||
A string of length L is called periodic with period p if the i-th character is equal to the (i+p)-th character for all i between 0 and L-p-1, inclusive. For example, the strings "CATCATC", "CATCAT", "ACTAC" and "ACT" are all periodic with period 3.
You are given a String[] dna. Concatenate the elements of dna and return the minimum number of replacements needed to make the resulting string periodic with period less than or equal to maxPeriod. Each replacement consists of changing a single character from one letter to any other letter. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Constraints | |||||||||||||
- | dna will contain between 1 and 50 elements, inclusive. | ||||||||||||
- | Each element of dna will contain between 1 and 50 characters, inclusive. | ||||||||||||
- | Each character in dna will be 'A','C','G' or 'T'. | ||||||||||||
- | maxPeriod will be between 1 and n, inclusive, where n is the number of characters in the concatenated string. | ||||||||||||
Examples | |||||||||||||
0) | |||||||||||||
| |||||||||||||
1) | |||||||||||||
| |||||||||||||
2) | |||||||||||||
| |||||||||||||
3) | |||||||||||||
| |||||||||||||
4) | |||||||||||||
|