Compute the unique prefix for the last in sorted array
j = 0 NEW_LINE sec_last = a [ size - 2 ] NEW_LINE last = a [ size - 1 ] NEW_LINE while ( j < min ( len ( sec_last ) - 1 , len ( last ) - 1 ) ) : NEW_LINE INDENT if ( sec_last [ j ] == last [ j ] ) : NEW_LINE INDENT j += 1 NEW_LINE DEDENT else : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT res [ ind ] = last [ 0 : j + 1 ] NEW_LINE return res NEW_LINE