[Solution] Complementary Strand in a DNA solution codechef

Complementary Strand in a DNA solution codechef – You are given the sequence of Nucleotides of one strand of DNA through a string SS of length NNSS contains the character A,T,C,A,T,C, and GG only.

Table of Contents

[Solution] Complementary Strand in a DNA solution codechef

Chef knows that:

  • AA is complementary to TT.
  • TT is complementary to AA.
  • CC is complementary to GG.
  • GG is complementary to CC.

Using the string SS, determine the sequence of the complementary strand of the DNA.

Input Format

  • First line will contain TT, number of test cases. Then the test cases follow.
  • First line of each test case contains an integer NN – denoting the length of string SS.
  • Second line contains NN characters denoting the string SS.

Complementary Strand in a DNA solution codechef

For each test case, output the string containing NN characters – sequence of nucleotides of the complementary strand.

Constraints

  • 1T1001≤T≤100
  • 1N1001≤N≤100
  • SS contains ATC, and G only

Sample Input 1 

4
4
ATCG
4
GTCC
5
AAAAA
3
TAC

Sample Output 1 

TAGC
CAGG
TTTTT
ATG

[Solution] Complementary Strand in a DNA solution codechef Explanation

Test case 11: Based on the rules, the complements of ATC, and G are TAG, and C respectively. Thus, the complementary string of the given string ATCG is TAGC.

Test case 22: Based on the rules, the complements of GT, and C are CA, and G respectively. Thus, the complementary string of the given string GTCC is CAGG.

Test case 33: Based on the rules, the complement of A is T. Thus, the complementary string of the given string AAAAA is TTTTT.

Test case 44: Based on the rules, the complements of TA, and C are AT, and G respectively. Thus, the complementary string of the given string TAC is ATG.

For Solution

Click Here

Leave a Comment