leetcode69
2024-09-29 05:04:32
public class Solution {
public int MySqrt(int x) {
long r = x;
while (r * r > x)
r = (r + x / r) / ;
return (int)r;
}
}
https://leetcode.com/problems/sqrtx/#/description
补充一个python的实现:
class Solution:
def mySqrt(self, x: int) -> int:
r = x
while r * r > x:
r = (r + x // r) //
return int(r)
使用内置函数:
class Solution:
def mySqrt(self, x: int) -> int:
return int(x ** 0.5)
最新文章
- 【hihoCoder】1121:二分图一·二分图判定
- 操作系统开发系列—10.内核HelloWorld ●
- Avalon学习
- HDU 4417 (划分树+区间小于k统计)
- 常用的正则表达式归纳—JavaScript正则表达式
- 【OpenCV学习笔记】之六 手写图像旋转函数---万丈高楼平地起
- -_-#【Canvas】measureText, translate, drawImage
- nginx gzip on
- myeclipse乱码问题和 编码设置
- oracle中row_number() over()
- 使用Visual Studio Team Services持续集成(四)——使用构建运行测试
- mysql设置对外访问
- 第 15 章 位操作(invert4)
- [leetcode]Sqrt(x) @ Python
- OAF_OAF控件系列4 - HGrid的实现(案列)
- Mycat跨分片Join
- postman 查看请求,已各种语言方式展示:
- C/C++ 标准
- 严重: Error configuring application listener of class org.springframework.web.context.ContextLoaderList
- 学习神器!本机安装虚拟机,并安装Linux系统,并部署整套web系统手册(包含自动部署应用脚本,JDK,tomcat,TortoiseSVN,Mysql,maven等软件)
热门文章
- poj3281网络流之最大流
- 【hive】时间段为五分钟的统计
- json.dumps与json.dump的区别 json.loads与json.load的区别(简洁易懂)
- maven+jmeter+jenkins集成
- redux中的compose源码分析
- antd中form自定义rules
- IO综合练习--文件切割和文件合并
- Codeforces 1006C:Three Parts of the Array(前缀和+map)
- 【传输协议】https SSL主流数字证书都有哪些格式?
- android高速上手(三)经常使用控件使用