We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
That is Brute force silution but not time env to examine all tests
functioncountApplesAndOranges(s:number,t:number,a:number,b:number,apples:number[],oranges:number[]):void{// Write your code hereletappleCount=0letorangeCount=0for(leti=0;i<apples.length;i++){apples[i]+=a}for(leti=0;i<oranges.length;i++){oranges[i]+=b}for(leti=s;i<=t;i++){for(letj=0;j<apples.length;j++){if(apples[j]==i){appleCount++}elseif(oranges[j]==i){orangeCount++}}}console.log(appleCount)console.log(orangeCount)}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Apple and Orange
You are viewing a single comment's thread. Return to all comments →
That is Brute force silution but not time env to examine all tests