Unique Number - II

Here is the code:- https://ide.codingblocks.com/s/420621, please mention the error in the code of the question.

Hello @Sakshi2004 i have corrected your code and commented the mistake:


if you have any doubt you can ask here:
Happy Learning!!

Hey, I am not able to understand why did the declaration of only x there and not y made such a difference. Please elaborate.

@Sakshi2004 this is because with the help of x you are finding the result or say evaluating whereas in y you are storing the final result.
if you are not initialising the x with 0 then it will have any garbage value in it that will create the problem because you are taking the arrays element xor with the random value present in the array and not with the 0.
this is the reason.

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.