Arm Interview Question

What was your thought process when solving this coding problem? What would you improve?