• + 0 comments
    // 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. 
    
    function acmTeam(persons) {
        let max = 0; // max topic that the team know 
        let count = 0; // the team which knows the max topics 
        
        for(let i = 0; i < persons.length; i++) { 
            for(let j = i + 1; j < persons.length; j++) {
                let know = 0; 
                for(let k = 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
                }
                else if(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 
    }