智慧屏安装APP的最佳实践与跨平台小程序开发的结合
606
2022-10-09
633. Sum of Square Numbers标题
Given a non-negative integer c, your task is to decide whether there’re two integers a and b such that a2 + b2 = c.
Example 1:
Input: 5Output: TrueExplanation: 1 * 1 + 2 * 2 = 5
Example 2:
Input: 3Output: False
public class Solution { public boolean judgeSquareSum(int c) { int beg = 0; int end = (int) Math.sqrt(c); while (beg <= end) { int target = beg * beg + end * end; if (target > c) { end--; } else if (target < c) { beg++; } else { return true; } } return false; } }
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~