Please login

Prime

Prepinsta Prime

Video courses for company/skill based Preparation

(Check all courses)
Get Prime Video
Prime

Prepinsta Prime

Purchase mock tests for company/skill building

(Check all mocks)
Get Prime mock

Problem 59

8 comments on “Problem 59”


  • Chanchala singh

    def lonely_integer(a):
    result = 0
    for i in a:
    result ^= i ”’XOR OPERATION
    A^A = 0
    0^B = B So, for each pair of numbers the xor operation results in 0.
    Since there is only one number that does not have a pair, the result is its lonly number,
    since 0^b =b (or b^0 = b).”’
    return result

    n=int(input())
    b = map(int,input().strip().split(” “))
    print(lonely_integer(b))


  • Srimukhi

    #include
    int main()
    {
    int i,a[100],n,j;
    scanf(“%d”,&n);
    for(i=0;i<n;i++)
    scanf("%d",&a[i]);
    for(i=0;i<n;i++)
    {
    for(j=i+1;j<n;j++)
    {
    if(a[i]==a[j])
    {
    a[i]=0;
    a[j]=0;
    }
    }
    }
    for(i=0;i<n;i++){
    if(a[i]!=0)
    printf("%d",a[i]);
    }
    }
    in c


    • HelpPrepInsta

      Here is a C code for this problem
      #include
      #define MAX_SIZE 100

      int main()
      {
      int arr[MAX_SIZE], freq[MAX_SIZE];
      int size, i, j, count;

      /* Input size of array and elements in array */
      printf(“Enter size of array: “);
      scanf(“%d”, &size);
      printf(“Enter elements in array: “);
      for(i=0; i


      • Tirtha

        n = int(input(‘Enter the number of integers in the array’))
        x = input().split()

        def countUnique(x, n):
        a = []
        for i in range(n):
        if x[i] in a:
        continue
        else:
        a.append(x[i])

        return len(a)

        b = countUnique(x, n)
        print(‘unique elements = {}’.format(b))