public static int prefixLength(String s1,String s2){
  int len=0;
  int max=Math.min(s1.length(),s2.length());
  for (int i=0; i < max && s1.charAt(i) == s2.charAt(i); ++i)   ++len;
  return len;
}

public static int prefixLength ( String s1 , String s2 ) { int len = 0 ; int max = Math . min ( s1 . length ( ) , s2 . length ( ) ) ; for ( int i = 0 ; i < max && s1 . charAt ( i ) == s2 . charAt ( i ) ; ++ i ) ++ len ; return len ; }
returns the length of the common prefix between s1 and s2 .
