LintCode题解之判断是否为平方数之和

 

 

简单粗暴

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/

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-16
  • 2021-09-30
  • 2021-12-21
  • 2021-06-22
猜你喜欢
  • 2021-10-06
  • 2022-12-23
  • 2022-12-23
  • 2022-02-24
  • 2021-08-22
  • 2021-09-26
  • 2022-12-23
相关资源
相似解决方案