• + 0 comments

    Optimization code in TypeScript

    function countApplesAndOranges(s: number, t: number, a: number, b: number, apples: number[], oranges: number[]): void {
        // Write your code here
        
        let appleCount=0
        let orangeCount=0
        
       for (let i of apples) {
        if (a+i>=s && a+i<=t)
            appleCount++;
        }
        for(let i of oranges) {
            if (b+i>=s && b+i<=t)
                orangeCount++;
        }
        
        console.log(appleCount)
        console.log(orangeCount)
    }