[LeetCode]633. Sum of Square Numbers
来源:互联网 发布:文化相对主义 知乎 编辑:程序博客网 时间:2024/06/06 03:40
https://leetcode.com/problems/sum-of-square-numbers/#/description
给一个数字c,判断是否满足a2 + b2 = c
双指针,end最大为c开根号,beg最小为0.判断当前beg和end是否满足,然后相应移动beg或者end
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; }}
阅读全文
0 0
- [leetcode]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
- LeetCode 633. Sum of Square Numbers
- leetcode 633. Sum of Square Numbers
- leetcode 633. Sum of Square Numbers
- [LeetCode]633. Sum of Square Numbers
- leetcode[Sum of Square Numbers]
- 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
- 633. Sum of Square Numbers。
- 【leetcode】633. Sum of Square Numbers(Python & C++)
- leetcode 633. Sum of Square Numbers 二分查找
- Object.assign 深层次合并
- Linux配置java环境变量
- Activity四种启动模式
- 使用WebUploader跨域上传图片,用SpringMVC实现服务器端
- 使用e.printStackTrace(PrintWriter s)对异常信息处理
- [LeetCode]633. Sum of Square Numbers
- webstorm中LESS环境的搭建
- 对象,基本类型的比较
- 进销存货物管理系统 论文
- 使用TCP协议的NAT穿透技术
- 蓝桥杯 分解质因数
- Codeforces 400D Dima And Bacteria 暴力+Floyd
- R语言-股票数据库(1)-股票上市日期
- 2014年上午卷错题知识点总结