The most interesting part to this problem is here imo (I time stamped it in the youtube video), where your first couple numbers are larger in the second array compared to the numbers in the first array.
The most important thing to note is that the first loop works while the n AND m indexes are greater than 0, which means as soon as the first arrays index hits 0 and the second array still has more to go, that loop exists and the second while loop take overs to finish the job.
A simple problem but with a small catch which might not be noticed on first glance if trying to work it out only mentally with no writing / draw ups.