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 apples, List oranges) {
// Write your code here
int nbrapples , nbroranges ;
nbrapples = apples.stream().map( d -> a + d )
.filter(d ->( d >= s && d <= t)).collect(toList()).size();
nbroranges = oranges.stream().map( d -> b + d )
.filter(d ->( d >= s && d <= t)).collect(toList()).size();
Apple and Orange
You are viewing a single comment's thread. Return to all comments →
public static void countApplesAndOranges(int s, int t, int a, int b, List apples, List oranges) { // Write your code here int nbrapples , nbroranges ; nbrapples = apples.stream().map( d -> a + d ) .filter(d ->( d >= s && d <= t)).collect(toList()).size(); nbroranges = oranges.stream().map( d -> b + d ) .filter(d ->( d >= s && d <= t)).collect(toList()).size();