2023 HUAWEI OD machine test real questions C language implementation [DNA sequence]

 Table of contents

topic

train of thought

test center

Code


topic

A DNA sequence is composed of four letters A/C/G/T. The ratio of G and C (defined as GC-Ratio) is the total number of occurrences of the two letters G and C in the sequence divided by the total number of letters (that is, the sequence length). In genetic engineering, this ratio is very important. Because the high GC-Ratio may be the starting point of the gene.
Given a very long DNA sequence and a limited substring length N, please help researchers find the first substring with the highest GC-Ratio and length N in the given DNA sequence from left to right.
The substrings with DNA sequence ACGT are: ACG , CG , CGT etc., but no AGT , CT etc.

Data range: the string length satisfies 1≤n≤1000, and the input string only contains A/C/G/T letters

Input description:
input a string-type gene sequence, and the length of an int-type substring

Output description:
Find the substring with the highest GC ratio, if there are more than one, output the first substring

Example 1:
Enter

Guess you like

Origin blog.csdn.net/misayaaaaa/article/details/132618517