Sort by

recency

|

1247 Discussions

|

  • + 0 comments

    The time constraints on these test cases are too tight. As in: for a C# solution, the additional time spent to instantiate variables at the start of the method for use and to increase code clarity, something even Exclaimer would value, rather than using the indices of the List being returned, is enough extra time to cause multiple test cases to fail. Integer instantiation takes a few microseconds. That's completely unreasonable. Insane, even.

  • + 0 comments

    Here is problem solution in Python, java, C++, C and Javascript - https://programmingoneonone.com/hackerrank-acm-icpc-team-problem-solution.html

  • + 0 comments

    Here is my c++ solution, you can watch the explanation here : https://youtu.be/fCUW_MhWEW8

    vector<int> acmTeam(vector<string> topic) {
        int h = 0, cp = 0;
        for(int i = 0; i < topic.size() - 1; i++){
            bitset<500> a = bitset<500>(topic[i]);
            for(int j = i + 1; j < topic.size(); j++){
             bitset<500> b = bitset<500>(topic[j]);
             bitset<500> c = a | b;
             int x = c.count();
             if( x > h){h = x; cp = 1;}
             else if( x == h) cp++;
            }
        }
        return {h, cp};
    }   
    
  • + 0 comments

    Typescript:

    function acmTeam(topic: string[]): number[] {
        // Write your code here
        const arrayOfMaximumTopics: number[] = [];
        let maximumTopics = 0;
        let numberOfTeams = 0;
        let totalAttendees: number = topic.length;
        
        for (let i = 0; i < totalAttendees - 1; i++) {
            for (let j = i + 1; j < totalAttendees; j++) {
                let topicsOfTeam = 0;
                const topicsCurrentAttendee: string[] = topic[i].split("");
                const topicsNextAttendee: 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];
    }
    
  • + 0 comments

    def acmTeam(topic): maxi=0 cou=0 for i in range(len(topic)-1): for j in range(i+1,len(topic)): subj = 0 for m,k in zip(topic[i],topic[j]): if(m=='1' or k=='1'): subj += 1

            if(maxi==subj):
                cou += 1
            elif(maxi<subj):
                cou=1
                maxi=subj
    return maxi,cou