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.
public static void countApplesAndOranges(int s, int t, int a, int b, List<Integer> apples, List<Integer> oranges) {
int appleCount = 0;
int orangeCount = 0;
for(int i = 0; i < apples.size(); i++){
if(apples.get(i) + a >= s && apples.get(i) + a <= t) {
appleCount++;
}
}
for(int i = 0; i < oranges.size(); i++){
if(oranges.get(i) + b >= s && oranges.get(i) + b <= t) {
orangeCount++;
}
}
System.out.println(appleCount);
System.out.println(orangeCount);
}
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, please critque if necessary -