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
想法:完全平方数是等差数列相加。
class Solution {
public:
    bool isPerfectSquare(int num) {
        ;
         ){
            num = num - x;
            x = x + ;
        }
        ;
    }
};

leetcode367--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_367. Valid Perfect Square

    367. Valid Perfect Square Easy Given a positive integer num, write a function which returns True if  ...

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

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

  5. [LeetCode] 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 else Fa ...

  7. 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 e ...

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

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

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

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

随机推荐

  1. Linux 安装redis,redis发布订阅,持久化

    安装redis 1.安装redis的方式 -yum (删除这个yum安装的redis,我们只用源码编译安装的) -rpm -源码编译 2.删除原本的redis yum remove redis -y ...

  2. 5月8日——iOS中的3D Touch效果

    需要在manifest.json文件中进行配置 需要执行的js代码为: 最终操作效果为 本篇文章主要采用了HTML5+  中的 launcher属性 具体可参照 http://www.html5plu ...

  3. 【读书笔记】iOS-网络-HTTP-请求内容

    一,GET方法. 从服务器获取一段内容,用HTTP术语来说就是实体.GET请求通常不包含请求体,不过也是可以包含的.有些网络缓存设施只会缓存GET响应.GET请求通常不会导致服务器端的数据变化. 二, ...

  4. AutoCAD.net支持后台线程-Socket通讯

    最近因为公司项目的需求,CAD作为服务端在服务器中常驻运行,等待客户端远程发送执行任务的指令,最终确认用Socket-tcp通讯,CAD需要实时监听客户端发送的消息,这时就需要开启线程执行Socket ...

  5. css实现3D立方体旋转特效

    先来看运行后出来的效果 它是在不停运行的一个立方体 先来看html部分的代码 <div class="rect-wrap"> <!--舞台元素,设置perspec ...

  6. C#取得控制台应用程序的根目录方法 判断文件夹是否存在,不存在就创建

    取得控制台应用程序的根目录方法1:Environment.CurrentDirectory 取得或设置当前工作目录的完整限定路径2:AppDomain.CurrentDomain.BaseDirect ...

  7. 让 Angular 应用动起来!

    [编者按]本文主要通过生动的实例,介绍为 Angular 应用添加动画的原理与过程.文章系国内 ITOM 管理平台 OneAPM 编译呈现. 我们知道,Angular 应用在更新 DOM 时,会直接将 ...

  8. IAM页面是在统一区分配的还是在混合区分配的?

    IAM页面是在统一区分配的还是在混合区分配的? IAM页面的作用这里就不说了,网上的资料很多 文章中用到的工具:查看SQLSERVER内部数据页面的小插件Internals Viewer 先建立四张表 ...

  9. 解决MySQL5.6中的Slave延迟问题的基本教程

    一.原因分析一般而言,slave相对master延迟较大,其根本原因就是slave上的复制线程没办法真正做到并发.简单说,在master上是并发模式(以InnoDB引擎为主)完成事务提交的,而在sla ...

  10. Java 设计模式笔记

    0. 说明 转载 & 参考大部分内容 JAVA设计模式总结之23种设计模式 1. 什么是设计模式 设计模式(Design pattern)是一套被反复使用.多数人知晓的.经过分类编目的.代码设 ...