My problem is to find the repeating sequence of characters in the given array. simply, to identify the pattern in which the characters are appearing.
.---.---.---.---.---.---.---.---.---.---.---.---.---.---. 1: | J | A | M | E | S | O | N | J | A | M | E | S | O | N | '---'---'---'---'---'---'---'---'---'---'---'---'---'---'
.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---. 2: | R | O | N | R | O | N | R | O | N | R | O | N | R | O | N | '---'---'---'---'---'---'---'---'---'---'---'---'---'---'---'
.---.---.---.---.---.---.---.---.---.---.---.---. 3: | S | H | A | M | I | L | S | H | A | M | I | L | '---'---'---'---'---'---'---'---'---'---'---'---'
.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---. 4: | C | A | R | P | E | N | T | E | R | C | A | R | P | E | N | T | E | R | '---'---'---'---'---'---'---'---'---'---'---'---'---'---'---'---'---'---'
Given the previous data, the result should be:
"JAMESON"
"RON"
"SHAMIL"
"CARPENTER"
A repeated sequence of numbers is an incremental list of numbers arranged in such a way that the difference in the successive numbers is 1, and each of these numbers is repeated for the specified number of times.
Tongue-in-cheek O(NlogN) solution
Perform an FFT on your string (treating characters as numeric values). Every peak in the resulting graph corresponds to a substring periodicity.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With