APT: DNA Reverse

Class

public class DNAReverse { public String reverse(String dna) { // fill in code here } }

Problem Statement

When sequencing DNA we often don't know if the digital output from the sequencer represents a 3'-5' strand or 5'-3' strand. To help determine the correct orientation we'd like to obtain the reverse of a specific strand, e.g., from "gcat" the reverse strand would be "tacg" (no complementary base-pairs are calculated, the strand is simply reversed.)

For a given strand of DNA represented as a string, return the reverse of the strand, also as a string.

The DNA strand will contain only cytosine, guanine, thymine, and adenine, represented by the characters 'c', 'g', 't', and 'a', respectively.

Constraints

Examples

  1. 
     "aaggttcc"
    
     Returns: "ccttggaa"
    
    

  2. 
     "atgta"
    
     Returns: "atgta"
    
    
    If the string is a palindrome, it's reverse is also a palindrome.

  3. 
     "ccggttaat"
    
     Returns: "taattggcc"
    
    

  4. 
     "t"
    
     Returns: "t"