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.
functionacmTeam(topic:string[]):number[]{// Write your code hereconstarrayOfMaximumTopics:number[]=[];letmaximumTopics=0;letnumberOfTeams=0;lettotalAttendees:number=topic.length;for(leti=0;i<totalAttendees-1;i++){for(letj=i+1;j<totalAttendees;j++){lettopicsOfTeam=0;consttopicsCurrentAttendee:string[]=topic[i].split("");consttopicsNextAttendee:string[]=topic[j].split("");topicsCurrentAttendee.forEach((el,index)=>{if(el==='1'||topicsNextAttendee[index]==='1'){topicsOfTeam++;}})if(topicsOfTeam>maximumTopics){maximumTopics=topicsOfTeam;}arrayOfMaximumTopics.push(topicsOfTeam);}}numberOfTeams=arrayOfMaximumTopics.filter(el=>el===maximumTopics).length;return[maximumTopics,numberOfTeams];}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
ACM ICPC Team
You are viewing a single comment's thread. Return to all comments →
Typescript: