Sort by

recency

|

3087 Discussions

|

  • + 0 comments

    My JS solution:

    function countApplesAndOranges(s, t, a, b, apples, oranges) {
        console.log(
            apples
                .map(apple => apple + a)
                .filter(apple => apple >= s && t >= apple).length
            );
        console.log(
            oranges
                .map(orange => b + orange)
                .filter(orange => orange <= t && orange >= s).length
            );
    }
    
  • + 0 comments

    This is my approach:

    function countApplesAndOranges(s, t, a, b, apples, oranges) {
        // Write your code here
        let counter = [0,0];
            
        apples.map(ap=>{
            if(((ap+a)>=s)&&((ap+a)<=t)) counter[0] ++;
        })
        oranges.map(or=>{
            if(((or+b)>=s)&&((or+b)<=t)) counter[1] ++;
        })
        return console.log(counter.join('\n'));
    }
    
  • + 0 comments

    THIS IS MY PYTHON CODE:

    #!/bin/python3
    
    import math
    import os
    import random
    import re
    import sys
    
    #
    # Complete the 'countApplesAndOranges' function below.
    #
    # The function accepts following parameters:
    #  1. INTEGER s
    #  2. INTEGER t
    #  3. INTEGER a
    #  4. INTEGER b
    #  5. INTEGER_ARRAY apples
    #  6. INTEGER_ARRAY oranges
    #
    
    def countApplesAndOranges(s, t, a, b, apples, oranges):
        apple_count = 0
        orange_count = 0
    
        for d in apples:
            if s <= a + d <= t:
                apple_count += 1
    
        for d in oranges:
            if s <= b + d <= t:
                orange_count += 1
    
        print(apple_count)
        print(orange_count)
    
    if __name__ == '__main__':
        first_multiple_input = input().rstrip().split()
        s = int(first_multiple_input[0])
        t = int(first_multiple_input[1])
    
        second_multiple_input = input().rstrip().split()
        a = int(second_multiple_input[0])
        b = int(second_multiple_input[1])
    
        third_multiple_input = input().rstrip().split()
        m = int(third_multiple_input[0])
        n = int(third_multiple_input[1])
    
        apples = list(map(int, input().rstrip().split()))
        oranges = list(map(int, input().rstrip().split()))
    
        countApplesAndOranges(s, t, a, b, apples, oranges)
    
  • + 0 comments

    The simplest way is using BeautyPlus—an AI-powered tool that lets you effortlessly clean up photos. Just paint over unwanted objects or people, and they disappear in seconds, leaving a flawless image. Whether it’s photobombers, blemishes, or distracting backgrounds, BeautyPlus’s AI Object Remover handles it seamlessly. No complex editing skills needed! Plus, it works on both quick touch-ups and detailed edits. Ideal for social media, professional shots, or personal memories, this tool ensures polished results every time. Try https://www.beautyplus.com/object-remover it to see how easily you can remove parts of the image and enhance your photos with just a few taps!

  • + 0 comments

    C Programming Solution:

    void countApplesAndOranges(int s, int t, int a, int b, int apples_count, int* apples, int oranges_count, int* oranges) {
        int count[2]={0,0};
        for(int i=0; i<2;i++){
            if(i==0){
                for(int j=0; j<apples_count;j++){
                    if((a+apples[j])>=s && (a+apples[j])<=t ){
                        (count[i])++;
                    }
                }
            }
            else{
                for(int j=0; j<oranges_count;j++){
                    if((b+oranges[j])>=s && (b+oranges[j])<=t ){
                        (count[i])++;
                    }
                }
            }
        }
        printf("%d\n%d",count[0],count[1]);
    }