简单粗暴

public class Solution {

    /*
* @param : the given number
* @return: whether whether there're two integers
*/
public boolean checkSumOfSquareNumbers(int n) {
int max = (int)Math.sqrt(n) + 1;
for(int i=0; i<max; i++){
for(int j=0; j<max; j++){
if(i*i + j*j == n) return true;
}
}
return false;
} };

 

题目来源: http://www.lintcode.com/zh-cn/problem/check-sum-of-square-numbers/

LintCode题解之判断是否为平方数之和的更多相关文章

  1. C#版 - Leetcode 633. 平方数之和 - 题解

    版权声明: 本文为博主Bravo Yeung(知乎UserName同名)的原创文章,欲转载请先私信获博主允许,转载时请附上网址 http://blog.csdn.net/lzuacm. C#版 - L ...

  2. [LeetCode] Sum of Square Numbers 平方数之和

    Given a non-negative integer c, your task is to decide whether there're two integers a and b such th ...

  3. C#刷遍Leetcode面试题系列连载(4) No.633 - 平方数之和

    上篇文章中一道数学问题 - 自除数,今天我们接着分析 LeetCode 中的另一道数学题吧~ 今天要给大家分析的面试题是 LeetCode 上第 633 号问题, Leetcode 633 - 平方数 ...

  4. [LeetCode] 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 th ...

  5. Java实现 LeetCode 633 平方数之和(暴力大法)

    633. 平方数之和 给定一个非负整数 c ,你要判断是否存在两个整数 a 和 b,使得 a2 + b2 = c. 示例1: 输入: 5 输出: True 解释: 1 * 1 + 2 * 2 = 5 ...

  6. 【JavaScript】Leetcode每日一题-平方数之和

    [JavaScript]Leetcode每日一题-平方数之和 [题目描述] 给定一个非负整数 c ,你要判断是否存在两个整数 a 和 b,使得 a2 + b2 = c . 示例1: 输入:c = 5 ...

  7. leetcode.双指针.633平方数之和-Java

    1. 具体题目 给定一个非负整数 c ,你要判断是否存在两个整数 a 和 b,使得 a^2 + b^2 = c. 示例1: 输入: 5 输出: True 解释: 1 * 1 + 2 * 2 = 5 注 ...

  8. 力扣(LeetCode)平方数之和 个人题解

    给定一个非负整数 c ,你要判断是否存在两个整数 a 和 b,使得 a2 + b2 = c. 示例1: 输入: 5 输出: True 解释: 1 * 1 + 2 * 2 = 5 示例2: 输入: 3 ...

  9. LeetCode 633. Sum of Square Numbers平方数之和 (C++)

    题目: Given a non-negative integer c, your task is to decide whether there're two integers a and b suc ...

随机推荐

  1. 无用代码清除tip

    测试提了个bug过来,说是有个ajax请求报404了. 我一看,后台代码被人删了,问了同事,因为实现机制变了,是应该删,但删多了. 把service和controller都恢复后,一个接口中除了我那个 ...

  2. 基于哈夫曼编码的文件压缩(c++版)

    本博客由Rcchio原创 我了解到很多压缩文件的程序是基于哈夫曼编码来实现的,所以产生了自己用哈夫曼编码写一个压缩软件的想法,经过查阅资料和自己的思考,我用c++语言写出了该程序,并通过这篇文章来记录 ...

  3. hdu1789 Doing Homework again---(经典贪心)

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1789 题目大意: 给出N个作业的截至日期,和N个作业不交所扣掉的分数,要求输出扣除分数做少的方案. ...

  4. CountDownLatch与thread-join()的区别

    今天学习CountDownLatch这个类,作用感觉和join很像,然后就百度了一下,看了他们之间的区别.所以在此记录一下. 首先来看一下join,在当前线程中,如果调用某个thread的join方法 ...

  5. Python 破解带密码保护的Zip文件

    今天发生了个有趣的事情,有个朋友发了一个带密码保护的Zip文件给我,却不给我密码,我就琢磨这怎么可以'猜'到密码呢? 经过一系列的尝试,最终使用python把这个密码给'猜'出来了.要想写出破解密码的 ...

  6. LinkedHashMap简明

    LinkedHashMap 构造方法摘要 inkedHashMap() 构造一个带默认初始容量 (16) 和加载因子 (0.75) 的空插入顺序LinkedHashMap 实例. LinkedHash ...

  7. Windows Socket的UDP和TCP编程介绍

    1:网络中进程之间如何通信 为了实现进程之间通信,首要解决的问题是如何唯一标识一个进程,在本地可以通过进程PID来唯一标识一个进程,但是在网络中则是行不通的,其实TCP/IP协议族已经帮我们解决了这个 ...

  8. MyBatis基础学习笔记--自总结

    一.MyBatis和jdbc的区别 jdbc的过程包括: 1.加载数据库驱动. 2.建立数据库连接. 3.编写sql语句. 4.获取Statement:(Statement.PrepareStatem ...

  9. [LeetCode] The Maze 迷宫

    There is a ball in a maze with empty spaces and walls. The ball can go through empty spaces by rolli ...

  10. 处处留心皆学问——由“display:inline-block;”导致的间距引发的思考。

    昨天在做一个demo时遇到了一个问题:我有五个li需要并排排列,然后自然而然的我给它们设了display:inline-block;但是,过了很久之后发现,除了我写的样式外,它默认有一个间距,我们都不 ...