367. Valid Perfect Square

PHOTO EMBED

Sun Apr 09 2023 08:32:45 GMT+0000 (Coordinated Universal Time)

Saved by @Ranjan_kumar #c++

class Solution {
public:
    bool isPerfectSquare(int num) {
        int l=1;
        int h=100000;
        long long mid=l+(h-l)/2;
        long long sq;
        while(l<=h)
        {
            sq=mid*mid;
            if(sq==num) return true;
            if(sq<num) l=mid+1;
            else h=mid-1;
            mid=l+(h-l)/2;
        }
        return false;
    }
};
content_copyCOPY

https://leetcode.com/problems/valid-perfect-square/