Given a positive integer num, write a function which returns True if num is a perfect square else False.

Follow up: Do not use any built-in library function such as sqrt.

&nbsp;
Example 1:
Input: num = 16
Output: true
Example 2:
Input: num = 14
Output: false

&nbsp;
Constraints:


	1 &lt;= num &lt;= 2^31 - 1


class Solution:
    def isPerfectSquare(self, num: int) -> bool:
        if num == 1:
            return True
        lo = 2
        hi = num // 2
        while lo <= hi:
            mid = lo + (hi - lo) //2
            print(mid)
            if mid * mid == num:
                return True
            if mid * mid > num:
                hi = mid - 1
            else:
                lo = mid + 1
        return False
class Solution {
    public boolean isPerfectSquare(int num) {
        long start = 1;
        long end = num;

        while(start<=end){
            long mid = start +(end - start)/2;

            if(mid*mid==num){
                return true;
            }
            else if(mid*mid<num){
                start = mid+1;
            }
            else
                end = mid-1;
        }
        return false;
    }
}
class Solution {
public:
    bool isPerfectSquare(int num) {

        if (num == 1)return true;
        long long l = 1, h = num / 2;

        while (l <= h) {
            long long mid = l + (h - l) / 2;
            long long midSqr = mid * mid;

            if (midSqr == num) return true;

            if (num < midSqr) {
                h = mid - 1;
            } else {
                l = mid + 1;
            }
        }
        return false;
    }
};
var isPerfectSquare = function(num) {
    let low = 1;
    let high = 100000;
    while(low <= high){
        let mid = (low + high) >> 1;
        let sqrt = mid * mid
        if( sqrt == num) {
            return true;
        
        }else if(num > sqrt ){
            low = mid + 1
        }else {
            high = mid - 1
        }
    }
    return false;
};
Valid Perfect Square