Skip to content

Latest commit

 

History

History
36 lines (28 loc) · 926 Bytes

32.md

File metadata and controls

36 lines (28 loc) · 926 Bytes
vector<vector<int>> findWinners(vector<vector<int>>& matches) {
        vector<int>notLost;
        vector<int>onceLost;

        unordered_map<int,int>lose_map;

        for(int i=0;i<matches.size();i++)
        {
           int lose=matches[i][1];
           lose_map[lose]++;
        }

        for(int i=0;i<matches.size();i++)
        {
            int w=matches[i][0];
            int l=matches[i][1];

            if(lose_map.find(w)==lose_map.end())
            {
                notLost.push_back(w);
                lose_map[w]=2;
            }

            if(lose_map[l]==1)
                onceLost.push_back(l);
        }
         sort(notLost.begin(),notLost.end());    
        sort(onceLost.begin(),onceLost.end());

        return {notLost,onceLost};

    }