当前位置:网站首页>【二分查找-简单】367. 有效的完全平方数
【二分查找-简单】367. 有效的完全平方数
2022-04-21 15:08:00 【菜菜2022】
题目
示例 1:
输入:num = 16
输出:true
示例 2:
输入:num = 14
输出:false
提示:
1 <= num <= 2^31 - 1
【代码】
class Solution:
def isPerfectSquare(self, num: int) -> bool:
left,right=1,num
while left<=right:
mid=left+(right-left)//2
if mid**2==num:
return True
elif mid**2<num:
left=mid+1
else:
right=mid-1
return False
版权声明
本文为[菜菜2022]所创,转载请带上原文链接,感谢
https://blog.csdn.net/kz_java/article/details/124270777
边栏推荐
- OpenHarmony相机用户态驱动框架
- Worm PWM
- It's been 2 years since the career change test. Give some advice to girls who are still hesitating
- MySQL8.0零基础入门之从青铜到钻石
- Technology sharing | black box testing methodology - boundary value
- 虫子 插入 希尔
- SAP UI5 应用开发教程之七十 - 如何使用按钮控件触发页面路由跳转试读版
- Mysql 执行流程
- Shell sed and gawk editors use
- 数字孪生坦克作战,科技推动战场信息数据化
猜你喜欢

阿里超大规模 Flink 集群运维体系介绍

MySQL 8.0.11安装教程(Windows版)

Spark SQL底层执行流程详解

【历史上的今天】4 月 21 日:微处理器先驱诞生;Winamp 发布;COPPA 正式生效

How to provide CPU branch prediction efficiency at the code level

Shell 的sed和awk 工具

Would like to ask how to find the software registration code from the database

pytorch图像分类篇: 花分类数据集下载和AlexNet网络搭建训练

Druid database link problem

Detailed explanation of basic knowledge of database 5: index and its two engines in mysql, master-slave replication and relational / non relational database
随机推荐
武汉科技大学C语言上机实验题(第一第二第三部分)
Insect makefile
Insecte dans Hill
Improvement of ref and struct in C 11
如何在代码层面提供CPU分支预测效率
What is the reason for this? Is there anything about MySQL installation
android. database. sqlite. SQLiteException: Can't downgrade database from version 2 to 1
【C语言】C语言标准库大梳理(超全)
存储系统及存储器
ThreadLocal应用及原理解析
如何在Nodejs项目中调用uniCloud云存储进行上传文件
lightGBM专题5:pyspark表数据处理之数据合并
数字化时代,企业运维面临现状及挑战分析解读
Lightgbm topic 4: lightgbm model saving under pyspark platform
让阿里P8都为之着迷的分布式核心原理解析到底讲了啥?看完我惊了
数字化时代,SaaS软件如何成为国产化替代的轻骑兵?
京东云重磅发布云电脑,面向未来打造无界办公体验
[today in history] April 21: microprocessor pioneer was born; Winamp release; Coppa comes into force
Technology sharing | black box testing methodology - boundary value
pytorch图像分类篇: 花分类数据集下载和AlexNet网络搭建训练