DNA Complement APT

Problem Statement

Each nucleotide has a complement: for 'a' it is 't' (and vice versa) and for 'c' it is 'g' (also vice versa). Although this complementarity is a chemical process, you'll write code to produce a digital complement for a strand. For a given strand of DNA represented as a string, return the complement of the strand, also as a string.

Definition

Class

public class DNAComplement { public String complement(String dna) { // fill in code here } }

Notes

Constraints

Examples

  1. "aaggttcc"
    
    
    Returns: "ttccaagg"

  2. "a"
    
    
    returns "t"

Owen L. Astrachan
Last modified: Wed May 2 14:33:41 EDT 2007