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<Integer> apples, List<Integer> oranges) { int noOfApples = 0; int noOfOranges = 0; apples = apples.stream().map(x -> x + a).collect(Collectors.toList()); oranges = oranges.stream().map(x -> x + b).collect(Collectors.toList()); for (int applePosi : apples) { if (applePosi >= s && applePosi <= t) { noOfApples++; } } for (int orangePosi : oranges) { if (orangePosi >= s && orangePosi <= t) { noOfOranges++; } } System.out.println(noOfApples); System.out.println(noOfOranges); }
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