find the common prefix between the first and last string
int i = 0 ; while ( i < end && a [ 0 ] . charAt ( i ) == a [ size - 1 ] . charAt ( i ) ) i ++ ; String pre = a [ 0 ] . substring ( 0 , i ) ; return pre ; }