ARRISE Interview Question

medium question with an optimal approach