My C# solution,but not efficient enough.


  • 0
    D

    '''
    public class Solution {
    public int[] SingleNumber(int[] nums) {
    int i,j;
    int[] p=new int[2];
    int k=1;
    int s=nums[0];
    for(;k<nums.Length;k++)
    {
    s^=nums[k];
    }
    for(i=0;i<nums.Length;i++)
    {
    for(j=i+1;j<nums.Length;j++)
    {
    if((s^nums[i]^nums[j])==0)
    {
    p[0]=nums[i];
    p[1]=nums[j];
    goto A;
    }
    }
    }
    A:return p;
    }
    }


Log in to reply
 

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