We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
JAVA 8 SOLUTION: its just very easy though i took a lot of time,soon will be pro in problem solving:) ;
public static void countApplesAndOranges(int s, int t, int a, int b, List apples, List oranges) {
int countApple=0;
int countOrange=0;
for(int i = 0; i < apples.size(); i++){
if(apples.get(i) + a >= s && apples.get(i) + a <= t ){
countApple++;
}
}
for(int i = 0; i < oranges.size(); i++){
if(oranges.get(i) + b >=s && oranges.get(i) + b <=t){
countOrange++;
}
}
System.out.println(countApple+"\n"+countOrange);
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Apple and Orange
You are viewing a single comment's thread. Return to all comments →
JAVA 8 SOLUTION: its just very easy though i took a lot of time,soon will be pro in problem solving:) ;
public static void countApplesAndOranges(int s, int t, int a, int b, List apples, List oranges) {