You are viewing a single comment's thread. Return to all comments →
Javascript:
function acmTeam(topic) { return coupleTeams(topic); } function coupleTeams(topics) { let maxTopics = 0; let maxCouples = 0; const len = topics.length; for (let i = 0; i < len -1; i++) { for(let j = 1; j + i < len; j++){ let numTopics = stringOrOnes(topics[i], topics[i+j]); if(numTopics > maxTopics){ maxTopics = numTopics; maxCouples = 1; } else if(numTopics == maxTopics) maxCouples++; } } return [maxTopics, maxCouples]; } function stringOrOnes(s1, s2){ const len = s1.length; let numOnes = 0; for(let i = 0; i < len; i++){ if(s1[i] == '1' || s2[i] == '1') numOnes++; } return numOnes; }
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 →
Javascript: