当前位置:网站首页>Leetcode69. x 的平方根
Leetcode69. x 的平方根
2022-07-30 01:02:00 【Java全栈研发大联盟】
题目传送地址:https://leetcode.cn/problems/sqrtx/submissions/
运行效率:
代码如下:
class Solution {
public static int mySqrt(int x) {
for(int i=0;i<=x;i++){
long powNum = (long) i * i; //这里要小心数字溢出的情况,所以用long类型
if(powNum>x){
return i-1;
}
}
return x;
}
}
边栏推荐
猜你喜欢

华为“天才少年”稚晖君又出新作,从零开始造“客制化”智能键盘

基于SSM实现个性化健康饮食推荐系统

自学HarmonyOS应用开发(47)- 自定义switch组件

Running a Fabric Application

CMake Tutorial Tour (1)_Basic starting point

News text classification

自学HarmonyOS应用开发(56)- 用Service保证应用在后台持续运行

高德地图jsapi不生效 INVALID_USER_SCODE
![[Training DAY16] ALFA [convex hull] [computational geometry]](/img/26/ecc77dabdf468b3a8ad3888b292496.png)
[Training DAY16] ALFA [convex hull] [computational geometry]

Linux-安装MySQL(详细教程)
随机推荐
He cell separation technology 丨 basic primary cell separation methods and materials
Recommendation systems: feature engineering, common features
【mysql】Mysql公用表表达式with as
Worthington's tried and tested cell isolation system protocols
转发和重定向的区别及使用场景
泰克Tektronix示波器软件TDS420|TDS430|TDS460上位机软件NS-Scope
How to realize the frame selection of objects in canvas (6)
【C Primer Plus第九章课后编程题】
Google Chrome (google) is set to translate Chinese, the translation option does not take effect or the translation option does not pop up
【经验】经验总结-经验教训
CMake Tutorial Tour (1)_Basic starting point
npm ERR! code ENOTSUPnpm ERR! notsup Unsupported engine for [email protected]: wanted: {“n
How Navicat Connects to MySQL
Fabric Writing Case Chaincode
Worthington Optimized Technology: Cell Quantification
自学HarmonyOS应用开发(53)- 获取当前位置
推荐系统:用户“行为数据”的采集【使用Kafaka、Cassandra处理数据】【如果与业务数据重合,也需要独自采集】
如何在AWS里面的SQL server设置混合登陆
遇到bug的解决办法,测试再也不背锅了
[MySQL series] MySQL database foundation