Given an integer n, return true if n has exactly three positive divisors. Otherwise, return false.

An integer m is a divisor of n if there exists an integer k such that n = k * m.

&nbsp;
Example 1:

Input: n = 2
Output: false
Explantion: 2 has only two divisors: 1 and 2.


Example 2:

Input: n = 4
Output: true
Explantion: 4 has three divisors: 1, 2, and 4.


&nbsp;
Constraints:


	1 &lt;= n &lt;= 104


import math
class Solution:
    def isThree(self, n: int) -> bool:
        primes = {3:1, 5:1, 7:1, 11:1, 13:1, 17:1, 19:1, 23:1, 29:1, 31:1, 37:1, 41:1, 43:1, 47:1, 53:1, 59:1, 61:1, 67:1, 71:1, 73:1, 79:1, 83:1, 89:1, 97:1}
        if n == 4:
            return True
        else:
            a = math.sqrt(n)

            if primes.get(a,0):
                return True
            else:
                return False
class Solution {
    public boolean isThree(int n) {
        if(n<4 ) return false;
        int res = (int)Math.sqrt(n);
        for(int i=2;i*i<n;i++){
            if(res%i ==0) return false;
        }
        return true;
}}
class Solution {
public:
    bool isPrime(int n) {
        for (int i = 2; i <= sqrt(n); i++) if (n % i == 0) return false;
        return true;
    }

    bool isThree(int n) {
        return n != 1 && n != 2 && (int)sqrt(n)*sqrt(n) == n && isPrime(sqrt(n));
    }
};
var isThree = function(n) {
    var set = new Set();
    for(var i = 1; i<=Math.sqrt(n) && set.size <= 3; i++)
    {
        if(n % i === 0)
        {
            set.add(i);
            set.add(n / i);
        }
    }
    return set.size===3;  
};
Three Divisors