Message on Whatsapp 8879355057 for DSA(OA + Interview) + Fullstack Dev Training + 1-1 Personalized Mentoring to get 10+LPA Job
0 like 0 dislike
5,119 views

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

Here is the link :  https://www.desiqna.in/tag/google_oa

in Online Assessments by Expert (34,270 points) | 5,119 views
0 0
Where do i found Solutions to these questions??

3 Answers

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 (108,110 points)
edited by
1 like 0 dislike

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

 

Question - 1
image

 


 

Question - 2
image

by Expert (34,270 points)
reshown by