🔥 [LeetCode The Hard Way] 🔥 Explained Line By Line
C++\n\ncpp\nclass Solution {\npublic:\n    int maxDivScore(vector<int>& nums, vector<int>& divisors) {\n        int ans = -1, mx_cnt = -1;\n        // for each 
C++\n\n```cpp\nclass Solution {\npublic:\n    int maxDivScore(vector<int>& nums, vector<int>& divisors) {\n        int ans = -1, mx_cnt = -1;\n        // for each divisor\n        for (auto d : divisors) {\n            int cnt = 0;\n            // we check each number `x`\n            for (auto x : nums) {\n                // to see if `x` can be divisible by `d`\n                if (x % d == 0) {\n                    // if so, increase the counter by 1\n                    cnt += 1;\n                }\n            }\n            // if the counter is greater than the current max\n            if (cnt > mx_cnt) {\n                // then update hte current max\n                mx_cnt = cnt;\n                // `d` will be the possible answer\n                ans = d;\n            } else if (cnt == mx_cnt) {\n                // however, if the counter is same as the current max\n                // then we need to take the min one\n                ans = min(ans, d);\n            }\n        }\n        return ans;\n    }\n};\n```\n\nPython\n\n```py\nclass Solution:\n    def maxDivScore(self, nums: List[int], divisors: List[int]) -> int:\n        res = -1\n        mx_cnt = -1\n        # for each divisor\n        for d in divisors:\n            cnt = 0\n            # we check each number `x`\n            for x in nums:\n                # to see if `x` can be divisible by `d`\n                if x % d == 0:\n                    # if so, increase the counter by 1\n                    cnt += 1\n            # if the counter is greater than the current max\n            if cnt > mx_cnt:\n                # then update hte current max\n                mx_cnt = cnt\n                # `d` will be the possible answer\n                res = d\n            elif cnt == mx_cnt:\n                # however, if the counter is same as the current max\n                # then we need to take the min one\n                res = min(res, d)\n        return res\n```
['Python', 'C++']