367. Valid Perfect Square

2016-12-22  本文已影响0人  我是你的果果呀

Given a positive integernum, write a function which returns True ifnumis a perfect square else False.

Note:Do notuse any built-in library function such assqrt.

Example 1:  Input: 16  Returns: True

Example 2: Input: 14   Returns: False

除了1 以外, 所以数的平方跟都小于等于这个数的二分之一, 二分查找法

上一篇 下一篇

猜你喜欢

热点阅读