367.Valid-Perfect-Square

367. Valid Perfect Square

题目地址

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

题目描述

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

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

Example 1:
Input: 16
Output: true

Example 2:
Input: 14
Output: false

代码

Approach #2 Newton's Method

Time O(logN) Space O(1)

Last updated

Was this helpful?