My code got a wrong answer, but it works well on eclipse!


  • 1
    Z

    There is a strange problem here. My code runs correctly on eclipse, while it gets a wrong answer here with the same input. Is there any thing wrong with the code?

    public class Solution {
    
    public int singleNumber(int[] A) {
        int a = 0, b = 0;
        for(int i = 0; i < A.length; i ++){
            a = a ^ b ^ A[i];
            b = a ^ b ^ A[i];
        }
        return a ^ b;
    }
    

    }


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.