Java Solution Beat 96% Easy Array Approach ✅💯
Intuition1. Iterate over each divisor:
We need to check how many elements in the nums array are divisible by each divisor from the divisors array. So, for each
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
**1. Iterate over each divisor:**
- We need to check how many elements in the nums array are divisible by each divisor from the divisors array. So, for each divisor, we will count the number of elements in nums that are divisible by it.

**2. Count divisible numbers:**
- For each divisor divisors[i], check each element in the nums array and see if it is divisible by divisors[i]. Increment a count for each element that is divisible by the current divisor.

**3. Track the maximum count:**
- If the current divisor yields a higher count than the previous maximum count, update the max and set the ans to the current divisor.
- If the current divisor yields the same count as the maximum count, update the ans to the smaller of the current ans and the current divisor, ensuring that we return the smallest divisor in case of a tie.

**4. Return the answer:**
- After iterating through all divisors, the variable ans will hold the divisor with the maximum count of divisible numbers (or the smallest divisor in case of a tie).

# Approach
<!-- Describe your approach to solving the problem. -->
**1. Iterate over each divisor:**
- We need to check how many elements in the nums array are divisible by each divisor from the divisors array. So, for each divisor, we will count the number of elements in nums that are divisible by it.

**2. Count divisible numbers:**
- For each divisor divisors[i], check each element in the nums array and see if it is divisible by divisors[i]. Increment a count for each element that is divisible by the current divisor.

**3. Track the maximum count:**
- If the current divisor yields a higher count than the previous maximum count, update the max and set the ans to the current divisor.
- If the current divisor yields the same count as the maximum count, update the ans to the smaller of the current ans and the current divisor, ensuring that we return the smallest divisor in case of a tie.

**4. Return the answer:**
- After iterating through all divisors, the variable ans will hold the divisor with the maximum count of divisible numbers (or the smallest divisor in case of a tie).

# Complexity
- Time complexity: O(n*m)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity: O(1)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```java []
class Solution {
    public int maxDivScore(int[] nums, int[] divisors) {
        int ans = 0;
        int max = Integer.MIN_VALUE;
        for (int i = 0; i < divisors.length; i++) {
            int count = 0;
            for (int j = 0; j < nums.length; j++) {
                if (nums[j] % divisors[i] == 0) {
                    count++;
                }
            }
            if (max == count) {
                ans = Math.min(ans, divisors[i]);
            } else if (max < count) {
                max = count;
                ans = divisors[i];
            }
        }
        return ans;
    }
}
```
['Array', 'Java']