• + 0 comments

    JS easy solution:-

    function countApplesAndOranges(s, t, a, b, apples, oranges) {
        const fallingFrutes = (startPoint, frutes) => {
            return frutes.reduce((acc, frute) => {
            const position = startPoint + frute;
            if (position >= s & position <= t) acc++;
            return acc;
            }, 0)
        }
        const appleFallsOnHouse = fallingFrutes(a, apples)
        console.log(appleFallsOnHouse);
        const orangesFallsOnHouse = fallingFrutes(b,oranges)
        console.log(orangesFallsOnHouse);
    }