leetcode 367. Valid Perfect Square
生活随笔
收集整理的這篇文章主要介紹了
leetcode 367. Valid Perfect Square
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
二分。
bool isPerfectSquare(int num) {if (num == 0 || num == 1)return true;int start = 0;int end = num;while (start <= end) {int chu = start + (end - start) / 2;int res = num / chu;if (res == chu && num % chu == 0)return true;if (chu > res)end = chu - 1;elsestart = chu + 1;}return false;}?
轉載于:https://www.cnblogs.com/willaty/p/8436009.html
總結
以上是生活随笔為你收集整理的leetcode 367. Valid Perfect Square的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: CSS3动画详解(图文教程)
- 下一篇: 不擅演讲的马化腾在 08 年讲了什么?