Given a string s, you need to transmit it over a network. The rules are: - If two adjacent characters in a segment are the same, it costs an extra sameTime seconds. - You may partition the string into any number of substrings; each cut costs partitionTime seconds. Find the…