MasTek (CA) interview question

Python Java DSA arrays logic