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.
this is very simple question
here are the solution of this problemStatement in java(8)
public static void countApplesAndOranges(int s, int t, int a, int b, List<Integer> apples, List<Integer> oranges) {
// Write your code here
int countApple = 0;
int countOrange = 0;
for (int i = 0; i < apples.size(); i++) {
if ((a + apples.get(i)) >= s && (a + apples.get(i)) <= 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);
System.out.println(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 →
this is very simple question here are the solution of this problemStatement in java(8)