SpaceX interview question

Do these two DSA problems and explain your thought process while doing them.