• + 0 comments

    That is Brute force silution but not time env to examine all tests

    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=0; i<apples.length; i++) {
            apples[i]+=a
        }
        for(let i=0; i<oranges.length; i++) {
            oranges[i]+=b
        }
        
        for(let i=s; i<=t; i++) {
            for(let j=0; j<apples.length; j++) {
                if(apples[j]==i) {
                    appleCount++
                } else if(oranges[j]==i) {
                    orangeCount++
                }
            }
        }
        
        console.log(appleCount)
        console.log(orangeCount)
    }