Merge Sorted Array
easyTime: O(n + m)Space: O(1)
Signals to notice
merge two sorted arrays in-placeat end of first arraythree pointers
Brute force first
Copy both into new array and merge. That direct path helps you understand the question, but it tends to treat every possibility as brand new instead of learning from earlier steps.
The key insight
Fill from the end using three pointers. Instead of recomputing the world every time, you preserve just enough context to let the next decision become obvious.
What must stay true
Fill from the back to avoid overwriting elements in nums1 that haven't been processed. As long as that statement keeps holding, you can trust the steps built on top of it.
Easy way to go wrong
Filling from the front — you'd overwrite elements in nums1 you still need. When the code becomes mechanical before the idea is clear, small edge cases start breaking the whole story.