Tell me why the following code is wrong?


  • 0
    G

    SingleNumber II:

    class Solution {
    public:
    int singleNumber(int A[], int n) {
    int count[32]={0};
    int result;
    for(int i=0;i<32;i++)
    {
    for(int j=0; j<n; j++)
    {
    if(abs(A[j]%2)==1)
    count[i]++;
    A[j]=A[j]/2;

    }
    }
    for(int i=31;i>=0;i--)
    {
    result =result*2+count[i]%3;
    }
    return result;
    }
    };

    Thank you


Log in to reply
 

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