title: Find largest common subsequence
body: <p>I have the following code, which does not work correctly for some reason that I am trying to figure out:</p>
  
  <pre><code>public static int score(String gene1, String gene2){
      char[] a=new char[gene1.length()];
      char[] b=new char[gene2.length()];
      a=gene1.toCharArray();
      b=gene2.toCharArray();
      return score(a, b, 0,0);
  }
  
  private static int score(char[] a, char[] b, int i, int j){
      if(a[i]=='\0' || b[j]=='\0')
          return 0;
      else if (a[i]==b[j])
          return 1+score(a, b, i+1, j+1);
      else 
          return max(score(a, b,i+1, j),score(a, b, i, j+1));
  }
  
  private static int max (int a, int b){
      if (a&lt;b) return b;
      else return a;
  }
  </code></pre>
  
  <p>Here is where it fails:</p>
  
  <pre><code>assertEquals(2, GeneAnalysis.score("ACGT","AC")); 
  </code></pre>
  
  <p>I get an IndexOutofBoundsError</p>
  
  <p>Any ideas? Also, when offering help, please do not change method parameters. They are supposed to be the way they are. </p>