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.
// i have chnages the given array from topics -> persons. // now understand, it like if person[i][k] == 1, that means ith person knows the topic k. functionacmTeam(persons){letmax=0;// max topic that the team know letcount=0;// the team which knows the max topics for(leti=0;i<persons.length;i++){for(letj=i+1;j<persons.length;j++){letknow=0;for(letk=0;k<persons[0].length;k++){if(persons[i][k]==='1'||persons[j][k]==='1'){know+=1;}}if(know>max){max=know;count=1;// reset the count for the nex max}elseif(know===max){count+=1;// otherwise increase the count, we found another max }}}return[max,count];// should i tell you a secret, >> you are g___r___e__a__t 😍!!// Happy Coding }
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 →