knakul853

Untitled

Jun 26th, 2020
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.36 KB | None | 0 0
  1. /**
  2. knakul853
  3. **/
  4. class Solution {
  5. public:
  6.     bool isPerfectSquare(int num) {
  7.      
  8.       int l = 0;
  9.       int h = num;
  10.       while(l<=h)
  11.       {
  12.         long long mid = (l+h)/2;
  13.         if(mid*mid==num)return true;
  14.         if(mid*mid>num)
  15.           h = mid-1;
  16.         else
  17.           l = mid+1;
  18.       }
  19.         return false;
  20.  
  21.      
  22.     }
  23. };
Add Comment
Please, Sign In to add comment