Given a DNA sequence consisting of the four nucleotide bases (A, C, G, T), count the number of substrings where no two consecutive characters represent the same nucleotide base.
Explanation: Step-by-step: with input ATCG, we split it into 'A', 'T', 'C', 'G', 'AT', 'TC', but exclude 'AT' and 'TC' because they have consecutive repeating nucleotide bases. So the correct count is 5.
Explanation: Step-by-step: with input AAAA, we split it into 'A', 'A', 'A', 'A', but exclude 'AA' because it has consecutive repeating nucleotide bases. So the correct count is 4.
Master coding challenges related to Strings and solve the [Backup] Analyzing Genome Sequences problem optimally.
No dry run loaded.
🚀 Practice this problem
Run code, get AI hints & track streak