当前位置:网站首页>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
- Data source object management (third-party object resources) & load properties file
- MySQL log management and full backup incremental backup and recovery
- 重写equals为什么要重写hashcode
- XX市高中网络拓扑整体规划配置
- In depth understanding of machine learning - unbalanced learning: sample sampling technology - [smote sampling method and borderline smote sampling method of manual sampling technology]
- The WinRAR command copies the specified folder as a compressed file, and calls the scheduled task for backup.
- Graphql first acquaintance
- Ncnn mat matrix class
- 05_服务调用Ribbon
猜你喜欢
Powertor500t reports an error 0x01806803
数据源对象管理(第三方对象资源) & 加载properties文件
Browser cannot open tensorboard
【模板记录】字符串哈希判断回文串
zsh: command not found: mysql
After 4 years of developing two-sided meituan, we finally lost: the interview question of volatile keyword function and principle
MySQL面试题(2022)
Monte Carlo based reinforcement learning method [with code implementation]
Polynomial interpolation fitting (II)
Envi: (the most detailed tutorial in 2022) custom coordinate system
随机推荐
Multi table query - case exercise
2002 - Can‘t connect to server on ‘127.0.0.1‘ (36)
洛谷每日三题之第四天
洛谷每日三题之第五天
洛谷每日三题之第三天(第四天补做)
oracle 查询非自增长分区的最大分区
After 4 years of developing two-sided meituan, we finally lost: the interview question of volatile keyword function and principle
ES6學習筆記——B站小馬哥
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“ )
Obvious things
leetcode:78. 子集
神经网络学习笔记2.2 ——用Matlab写一个简单的卷积神将网络图像分类器
Zabbix6.0 monitors Dell and IBM server hardware through Idrac and imm2
Can't access this website can't find DNS address DNS_ PROBE_ What about started?
The installation software prompts that the program input point adddlldirectory cannot be located in the dynamic link library kernel32 DLL (download address at the end of the text)
ubuntu清除cuda缓存
ncnn DataReader&Extractor&blob
We should increase revenue and reduce expenditure
通过Dao投票STI的销毁,SeekTiger真正做到由社区驱动
Leetcode: multiple knapsack problem in dynamic programming [one template solves all ~]