leetcode Valid Perfect Square

leetcode 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:

Example 2:

题目地址:leetcode Valid Perfect Square

题意:给定一个数n,要求不使用sqrt函数判断该数是否为完全平方数

思路:二分。。  L = 1 ,  R = num / 2 +1开始枚举即可。。。

C++

Java

Python

 

 

本题是leetcode 367  Valid Perfect Square题解

更多题解可以查看:https://www.hrwhisper.me/leetcode-algorithm-solution/

本博客若无特殊说明则由 hrwhisper 原创发布
转载请点名出处:细语呢喃 > leetcode Valid Perfect Square
本文地址:https://www.hrwhisper.me/leetcode-valid-perfect-square/

听说帅的人已经打赏了

Leetcode , , , , . permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *