Optimized Java Solution | Easy-Structured | With Comments and Approach
Approach\nWe will iterate through all the divisors and check how many of the numbers they can divide. While doing this, we will keep track of the divisor which 
# Approach\nWe will iterate through all the divisors and check how many of the numbers they can divide. While doing this, we will keep track of the divisor which divided maximum of numbers.\n\nNote: The only thing that can cause error in this problem is the edge condition. i.e. if the maximum count is same, we need to return the minimum divisor that had that score. Hence, we need to add an extra condition for it.\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O(M*N)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public int maxDivScore(int[] nums, int[] divisors) {\n        int maxScore=-1;\n        int maxElement=-1;\n        for(int i=0;i<divisors.length;i++){\n            // count of numbers ith divisor can divide\n            int score=0;\n            for(int j=0;j<nums.length;j++){\n                if(nums[j]%divisors[i]==0)\n                    score++;\n            }\n\n            // updating max count\n            if(score==maxScore) // edge condition\n                maxElement=Math.min(maxElement,divisors[i]);\n            else if(score>maxScore){\n                maxScore=score;\n                maxElement=divisors[i];\n            }\n        }\n        return maxElement;\n    }\n}\n```
['Java']