Message on Whatsapp 8879355057 for DSA(OA + Interview) + Fullstack Dev Training + 1-1 Personalized Mentoring to get 10+LPA Job
0 like 0 dislike
2,553 views
in Online Assessments by Expert (108,100 points) | 2,553 views

3 Answers

0 like 0 dislike
Best answer

Super Hard Codenation OA live problem solving video of today :

 

 

C++ Code : 

#include <bits/stdc++.h>

using namespace std;
typedef long long int ll ; 
int main() {
    
    ll n;
    cin>>n;
    ll a[n+1]={0};
    ll i = 1 ; 
    while(i<=n){
        cin>>a[i];
        i++;
    }
    
    ll b[40] = {0};
    unordered_map <ll,ll> kk ;
    kk[0]++;
    i = 1 ; 
    ll osi = 0 ; 
    while(i<=n){
        ll y = a[i];
        
        ll gg = 0 ; 
        //j--->row_number
        for(int j=30;j>=0;j--){
            int k = y >> j ;
            if(k&1){
                b[j]++;
            }
            
            if(b[j]%2!=0){
                ll vv = (1<<j);
                gg = (gg)^(vv);
            }
            
            
            
        }
        
        
        
        //cout<<gg;--->decimal conversion of current status....
        
        
        osi = osi + kk[gg] ; 
        
        
        kk[gg] = kk[gg] + 1 ;
        
        
        i++;
    }
    
    cout<<osi ; 
    
    
    return 0; 
    
}
by Expert (108,100 points)
edited by
0 like 0 dislike
by Expert (108,100 points)
0 like 0 dislike

Image of Question: 

Tc : 

N = 1 

Output : 0

N = 4 

1 0 3 2

Output : 2

 

by Expert (108,100 points)