633. Sum of Square Numbers标题
2017-08-09 23:02
330 查看
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:
Example 2:
Example 1:
Input: 5 Output: True Explanation: 1 * 1 + 2 * 2 = 5
Example 2:
Input: 3 Output: 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; } }
相关文章推荐
- 633. Sum of Square Numbers
- leetcode 633. Sum of Square Numbers 二分查找+勾股定理
- 633. Sum of Square Numbers
- LeetCode 633. Sum of Square Numbers
- leetcode 633. Sum of Square Numbers
- 633. Sum of Square Numbers
- [leetcode]633. Sum of Square Numbers
- 633. Sum of Square Numbers
- Leetcode 633. Sum of Square Numbers(Easy)
- 633. Sum of Square Numbers
- LeetCode 633. Sum of Square Numbers
- leetcode 633. Sum of Square Numbers
- [Leetcode] 633. Sum of Square Numbers 解题报告
- 【leetcode】633. Sum of Square Numbers(Python & C++)
- LeetCode 633. Sum of Square Numbers
- 633. Sum of Square Numbers。
- 633. Sum of Square Numbers (数学)
- 633. Sum of Square Numbers
- 633. Sum of Square Numbers
- [leetcode]633. Sum of Square Numbers