0 like 0 dislike
5,595 views

All past online assesments of Google can be found using the tag "google_oa" in the search bar.

| 5,595 views
0 0
Where do i found Solutions to these questions??

0 like 0 dislike
#include <iostream>

#include <string>

#include<bits/stdc++.h>

using namespace std;

int main()

{

unordered_map<int,int> m;

int ans=0;

int n,c,d;

cin>>n>>c>>d;

int a[n],b[n];

for(int i=1;i<=n;i++)

{

cin>>a[i];

}

for(int i=1;i<=n;i++)

{

cin>>b[i];

}

for (int j=1;j<n;j++)

{

int ith=a[j]-b[j];

m[ith]++;

int jth=ith+(d-c);

m[jth]++;

if (m[ith]==m[jth]) ans++;

//ans+=m[jth];

//m[ith]+=1;

}

cout<<ans;

}

/*

a[i]-b[i]==a[j]-b[j]+(d-c);

N = 5

C = 1

D = 2

A = [1 2 3 4 5]

B = [5 6 8 8 8}

5 1 2

1 2 3 4 5

5 6 8 8 8

*/
by (140 points)
0 like 0 dislike

TIme - 1 hr
Platform - HackerEarth
Location - India
On-Campus

by Expert (111,330 points)
edited
1 like 0 dislike

Number of Questions - 2
TIme - 1 hr
Platform - HackerEarth
Location - India
On-Campus

Question - 1

Question - 2

by Expert (34,270 points)
reshown