Apologies for any incorrect usage of maths notation in my explanation. Assume I have two sequences $A$ and $B$, I want to obtain a new sequence that contains all the elements from both $A$ and $B$ up to the first occurrence where they differ (appearing only once), and then it should include all the elements from both $A$ and $B$ that come after this first difference.
For example, given sequence $A = (a, b, c, d)$ and sequence $B = (a, b, d, c)$, the expected result for sequence $C$ is $(a, b, c, d, d, c)$.
I have an idea, but I'm not sure if it is appropriate. For sequence $A$,$B$ with length $n$,$m$ respectively, let $k$ be the smallest index of $A_i\neq B_i$, i.e. $k=\min\{i|A_i\neq B_i \}$, then the new sequence should be $C=A_{1:k-1}\cup A_{k:n}\cup B_{k:m}$.
My uncertainty lies in whether the symbol "$\cup$" can be used for combining sequences. I would greatly appreciate it if someone could provide a more concise and rigorous representation or confirm the correctness of my idea.