Pair of roses getting WA

I have used hashing, O(n) solution, it may give TLE but why is it giving WA, and how to approach for D&Q solution.

Hello @pratyush34 this question’s code can be implemented with the help of two pointer as well .
but make sure that you should minimise your answer as well.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.