RMS Interview Question

Walk me through your though process to implement this logic