beyondgrader.com Logo
DemoBrowseAboutTeamLogin

Count DNA Subsequence

Geoffrey Challen // 2021.2.0

Declare and implement a method called countDNASubsequence. It should take two nullable String arguments: the first a strand of DNA to examine, and the second a sequence to look for. It should return as an Int the number of nonoverlapping times that the sequence appears in the strand. Both the strand and the sequence will be entirely made up of only the characters 'A', 'T', 'G', and 'C', corresponding to the DNA base pairs.

For example, given the DNA strand AAAAAAAA and the sequence AA you should return 4, not 7, since the subsequence AA only appears 4 non-overlapping times in the strand.

If DNA or sequence is null or empty you should return 0.