Advertisement
dvjsharma

Find Missing Number

Jan 22nd, 2023
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1.     public:
  2.     vector<long long> findMissing(long long A[], long long B[],  
  3.                  int N, int M)
  4.     {
  5.         vector<long long>hsh1(1e12,0);
  6.         vector<long long>hsh2(1e12,0);
  7.         for(int i=0; i<1e12; i++){
  8.             hsh1[A[i]+1e6]++;
  9.         }
  10.         for(int i=0; i<1e12; i++){
  11.             hsh2[B[i]+1e6]++;
  12.         }
  13.         for(int i=0; i<1e12; i++){
  14.             if(hsh1[i]>0 && hsh2[i]==0){
  15.                 cout<<i<<endl;
  16.             }
  17.             else if(hsh1[i]==0 && hsh2[i]>0){
  18.                 cout<<i<<endl;
  19.             }
  20.         }
  21.        
  22.        
  23.     }
Tags: Doubt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement