367 Valid Perfect Square
367. Valid Perfect Square
1. Question
Given a positive integernum, write a function which returns True ifnumis a perfect square else False.
Note:Do not use any built-in library function such assqrt
.
Example 1:
Example 2:
2. Implementation
(1) Binary Search
3. Time & Space Complexity
Binary Search: 时间复杂度O(logn), 空间复杂度O(1)
Last updated