• + 0 comments

    java, please critque if necessary -

    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);
    }