You have a set which originally contains numbers from $1$ to $n$. One number got duplicated to another number, making one number appear twice and one number missing.
Find the number that occurs twice and the number that is missing. Return them as $[\text{duplicate}, \text{missing}]$.
For example, if the array is $[1, 2, 2, 4]$, the answer is $[2, 3]$ because $2$ appears twice and $3$ is missing.