APT: Longest Strand

Class

public class LongStrand { public String longest(String[] strands) { // fill in code here } }

Problem Statement

The length of a DNA strand determines some of its characteristics. Write code to find the longest strand of DNA in an array of strands. The longest strand is the strand with the most nucleotides, simply the longest string in the array of strings. If there is more than one maximally long strand return the one that has the lowest index, e.g., the first maximal strand.

Constraints

Examples

  1. 
     strands = {"CGATT", "CGA", "CGATTT" }
    
     Returns: "CGATTT"
    
    
    There is one maximal-length strand, return it.

  2. 
      strands = {"CGATAGC", "CGAT", "TCAG", "CGATTTT"}
    
      Returns: "CGATAGC"
    
    
    There are two strands of 7 characters, return the first one.

  3.   strands = {"CGT"}
    
      Returns: "CGT"