compute common prefix of a [ i ] unique from its right neighbor
j = 0 ; while ( j < Math . min ( a [ i ] . length ( ) - 1 , a [ i + 1 ] . length ( ) - 1 ) ) { if ( a [ i ] . charAt ( j ) == a [ i + 1 ] . charAt ( j ) ) j ++ ; else break ; } String new_prefix = a [ i ] . substring ( 0 , j + 1 ) ;