Doubt in codeforces

Please tell my mistake !

https://codeforces.com/contest/1515/problem/A

hello @prerak_semwal

when u are trying to swap w[i] with w[i+1] then make sure that i+1 < n

otherwise u might swap some garbage value which will give unexpected result.

to avoid it.
first compute the total sum if it is x then print no otherwise

u can easily use ur swapping logic without any modification

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.