➽ Problem:-
https://www.hackerrank.com/challenges/apple-and-orange/problem
➽ Solution:-
import
java.util.*;
import
java.io.*;
class
Solution
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
int a, b, c, d, x, y, apple, orange;
int apple_count=0, orange_count=0;
a = sc.nextInt();
b = sc.nextInt();
c = sc.nextInt();
d = sc.nextInt();
x = sc.nextInt();
y = sc.nextInt();
for(int i=0; i<x; i++)
{
apple = sc.nextInt();
if(c+apple >= a &&
c+apple <= b)
apple_count++;
}
for(int i=0; i<y; i++)
{
orange = sc.nextInt();
if(d+orange >= a &&
d+orange <= b)
orange_count++;
}
System.out.println(apple_count);
System.out.println(orange_count);
}
}
0 Comments
Please do not enter any spam link in the comment section.