99%fast||C++||Best Approach
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Code\n\nclass Solution {\npublic:\n    int maxDivScore(vector<int>& nums, vector<in
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Code\n```\nclass Solution {\npublic:\n    int maxDivScore(vector<int>& nums, vector<int>& divisors) {\n       sort(nums.begin(), nums.end());\n        int maxi = *max_element(nums.begin(), nums.end());\n        map<int, int>mp;\n       for(int i = 0; i<divisors.size(); i++)\n       {\n           int count = 0;\n           for(int j = divisors[i]; j<=maxi; j = j+divisors[i])\n           {\n               int l = lower_bound(nums.begin(), nums.end(), j)-nums.begin();\n               int u = upper_bound(nums.begin(), nums.end(), j)-nums.begin();\n               if(nums[l] == j)\n               {\n                   count = count+(u-l);\n               }\n           }\n           mp[divisors[i]] = count;\n           //cout<<count<<" ";\n       }\n        \n        int ans = INT_MIN;\n        int max = INT_MAX;\n        for(auto i : mp)\n        {\n            if(i.second>ans)\n            {\n                ans = i.second;\n                max = i.first;\n            }\n            else if(i.second==ans)\n            {\n                if(i.first < max)\n                {\n                    max = i.first;\n                }\n            }\n        }\n        return max;\n    }\n};\n```
['C++']