Similar DNA Under Rotation and Substitution
Problem statement
Given a reference DNA string and candidate DNA strings, count how many candidates have some circular rotation whose Hamming distance from the reference is at most three.
Only substitutions are allowed; insertion and deletion are not allowed.
Function
countSimilarDNA(reference: String, candidates: String[]) → intExamples
Example 1
reference = "AAAAG"candidates = ["AAAGA","CCCCC","AAAAT"]return = 2AAAGA matches after rotation, AAAAT needs one substitution, and CCCCC needs more than three.
Constraints
1 <= reference.length <= 200.1 <= candidates.length <= 1000.- Every string contains only
A,C,G, andT.