Leetcode 367 Solution
This article provides solution to leetcode question 367 (valid-perfect-square)
Access this page by simply typing in "lcs 367" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/valid-perfect-square
Solution
class Solution:
def isPerfectSquare(self, num: int) -> bool:
l = 0
r = num
while l < r:
m = (l + r) // 2
if m * m >= num:
r = m
else:
l = m + 1
return l * l == num