当前位置:网站首页>367. Effective complete square (necessary for entry)
367. Effective complete square (necessary for entry)
2022-07-19 03:28:00 【only-qi】
Problem description :
Given a Positive integer num , Write a function , If num It's a complete square , Then return to true , Otherwise return to false .
Advanced : Don't Use any built-in library functions , Such as sqrt .
Example :
Example 1:
Input :num = 16
Output :true
Example 2:
Input :num = 14
Output :false
Tips :
1 <= num <= 2^31 - 1
Code up , Take it to run :
package com.onlyqi.test03.erfen;
/**
* @author onlyqi
* @date 2022/7/11 19:42
* @description
*/
public class Test03 {
public static void main(String[] args) {
System.out.println("======================"+guess(36));
}
public static Boolean guess(int n){
int start=1;
int end =n;
while(end>=start) {
int mid = (start + end) / 2;
if(mid*mid==n){
return true;
}
if(n<mid*mid){
end=end-1;
}else {
start=start+1;
}
}
return false;
}
}
Running results : Input 36

I want to brush it 300 Algorithm questions , The first 104 Avenue
边栏推荐
- MySQL optimized index
- Can't access this website can't find DNS address DNS_ PROBE_ What about started?
- Pure virtual function
- Leetcode: 0-1 knapsack problem in dynamic programming [come and set the template directly]
- Latest installation tutorial of VMware Tools (rhel8)
- oracle 查询 主机名和对应的IP地址
- 数据源对象管理(第三方对象资源) & 加载properties文件
- 无线用的鉴权代码
- Bisenetv2 face segmentation
- Replacement operation not supported by ncnn partial operators
猜你喜欢

Comparison between redis and other databases
![[MySQL] MHA high availability](/img/d3/d9830f3c331193fd40b8f00ebe35fa.png)
[MySQL] MHA high availability

CorelDRAW cannot be installed. Solution

After 4 years of developing two-sided meituan, we finally lost: the interview question of volatile keyword function and principle

XX市高中网络拓扑整体规划配置

Vscode+ros2 environment configuration

Ubuntu clear CUDA cache

Powertor500t reports an error 0x01806803

Polynomial interpolation fitting (II)

05_服务调用Ribbon
随机推荐
CorelDRAW cannot be installed. Solution
Ncnn allocator memory allocator
2022-07-16: what is the output of the following go language code? A:[]; B:[5]; C:[5 0 0 0 0]; D:[0 0 0 0 0]。 package main import ( “fmt“ )
04_ Service registration Eureka
Yolov5 opencv DNN reasoning
[MySQL] MHA high availability
leetcode 222. 完全二叉树的节点个数(必会)
oracle 查询非自增长分区的最大分区
Cmake common commands
module_ Basic principle of init function
洛谷每日三题之第五天
Polynomial interpolation fitting (I)
重写equals为什么要重写hashcode
Display zabbix6.0 information using grafana8.5.2
Automatic assembly & set injection
ES6 learning notes - brother Ma at station B
RESNET learning notes
mysql复制表
Bisenetv1 face segmentation
深入理解机器学习——类别不平衡学习(Imbalanced Learning):样本采样技术-[人工采样技术之ADASYN采样法]