class Solution {
public:
bool isPerfectSquare(int num) {
int subNum = 1;
while (num > 0) {
num -= subNum;
subNum += 2;
}
return num == 0;
}
};
367 https://leetcode-cn.com/problems/valid-perfect-square/
最新推荐文章于 2022-08-10 20:28:03 发布