<p>Given an integer array <code>nums</code>, return <em>the sum of divisors of the integers in that array that have exactly four divisors</em>. If there is no such integer in the array, return <code>0</code>.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> nums = [21,4,7]
<strong>Output:</strong> 32
<strong>Explanation:</strong> 
21 has 4 divisors: 1, 3, 7, 21
4 has 3 divisors: 1, 2, 4
7 has 2 divisors: 1, 7
The answer is the sum of divisors of 21 only.
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> nums = [21,21]
<strong>Output:</strong> 64
</pre>

<p><strong class="example">Example 3:</strong></p>

<pre>
<strong>Input:</strong> nums = [1,2,3,4,5]
<strong>Output:</strong> 0
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= nums.length &lt;= 10<sup>4</sup></code></li>
	<li><code>1 &lt;= nums[i] &lt;= 10<sup>5</sup></code></li>
</ul>

class Solution {
public:
    vector<int> count_divisors(int n) {
        vector<int> ans;
        // check all divisors from 1 to number itself
        for (int i = 1; i <= sqrt(n); i++) {
            if (n % i == 0) {
                ans.push_back(i);
                // for second divisor: no/i:
                if ((n / i) != i) {
                    // do not add same divisor twice
                    ans.push_back(n / i);
                }
            }
        }
        cout << "\nAll divisiors of number " << n << " are: ";
        for (auto it : ans) {
            cout << it << " ";
        }
        return ans;
    }

    int sumFourDivisors(vector<int>& nums) {
        int noOfDivisors = 0;
        int sum = 0;
        // find out how many divisors does each no has:
        for (auto it : nums) {
            vector<int> divisors = count_divisors(it);
            noOfDivisors = divisors.size();
            if (noOfDivisors == 4) {
                // exactly 4 divisors so add them up & return ans;
                for (auto ele : divisors) {
                    sum += ele;
                }
            }
        }
        // If there is no such integer in the array, return 0
        return sum;
    }
};
37900