Apple and Orange | Hackerrank Solution in C++
Apple and Orange | Hackerrank Solution
It is an hackerrank problem you can find it by clicking here. Below given solution is prepared by one of the coder of our. Soultion in C++
#include<iostream>
using namespace std;
int main(){ int s,t,a,b,m,n; cin>>s>>t>>a>>b>>m>>n; int app=0,orange=0; for(int i=0;i<m;i++) { int d1; cin>>d1; if((a+d1)>=s && (a+d1)<=t) app++; } for(int j=0;j<n;j++) { int d2; cin>>d2; if((b+d2)>=s && (b+d2)<=t) orange++; } cout<<app<<"\n"<<orange; return 0;}
It is an hackerrank problem you can find it by clicking here.
Below given solution is prepared by one of the coder of our.
Soultion in C++
#include<iostream>
using namespace std;
int main()
{
int s,t,a,b,m,n;
cin>>s>>t>>a>>b>>m>>n;
int app=0,orange=0;
for(int i=0;i<m;i++)
{
int d1;
cin>>d1;
if((a+d1)>=s && (a+d1)<=t)
app++;
}
for(int j=0;j<n;j++)
{
int d2;
cin>>d2;
if((b+d2)>=s && (b+d2)<=t)
orange++;
}
cout<<app<<"\n"<<orange;
return 0;
}

Comments
Post a Comment