当前位置:网站首页>20220604 Mathematics: square root of X
20220604 Mathematics: square root of X
2022-07-03 10:11:00 【Seeyouagain】
Title Description : Give you a nonnegative integer x
, Calculate and return x
Of Arithmetical square root . Because the return type is an integer , Results are retained only Integral part , The decimal part will be Give up .
coded :
public int mySqrt(int x) {
int left = 0, right = x;
while (left <= right) {
int mid = (left + right) / 2;
long pow = (long) mid * mid;
if (pow > x) {
right = mid - 1;
} else if (pow < x) {
left = mid + 1;
} else {
return mid;
}
}
return right;
}
边栏推荐
- 使用密钥对的形式连接阿里云服务器
- Opencv notes 20 PCA
- Working mode of 80C51 Serial Port
- On the problem of reference assignment to reference
- Leetcode-112:路径总和
- LeetCode - 933 最近的请求次数
- CV learning notes alexnet
- Tensorflow2.0 save model
- My notes on the development of intelligent charging pile (III): overview of the overall design of the system software
- CV learning notes - Stereo Vision (point cloud model, spin image, 3D reconstruction)
猜你喜欢
2021-10-27
LeetCode - 706 设计哈希映射(设计) *
Adaptiveavgpool1d internal implementation
CV learning notes - camera model (Euclidean transformation and affine transformation)
Yocto technology sharing phase IV: customize and add software package support
What can I do to exit the current operation and confirm it twice?
Yocto Technology Sharing Phase 4: Custom add package support
Leetcode - 933 number of recent requests
yocto 技術分享第四期:自定義增加軟件包支持
Pycharm cannot import custom package
随机推荐
LeetCode - 706 设计哈希映射(设计) *
Leetcode - 1670 conception de la file d'attente avant, moyenne et arrière (conception - deux files d'attente à double extrémité)
Wireshark use
Working mode of 80C51 Serial Port
Opencv image rotation
Leetcode 300 longest ascending subsequence
Modelcheckpoint auto save model
Opencv feature extraction sift
Opencv Harris corner detection
Google browser plug-in recommendation
Leetcode-513: find the lower left corner value of the tree
Stm32 NVIC interrupt priority management
CV learning notes - Stereo Vision (point cloud model, spin image, 3D reconstruction)
Drive and control program of Dianchuan charging board for charging pile design
When the reference is assigned to auto
QT is a method of batch modifying the style of a certain type of control after naming the control
. DLL and Differences between lib files
LeetCode - 1172 餐盘栈 (设计 - List + 小顶堆 + 栈))
Flutter 退出当前操作二次确认怎么做才更优雅?
20220602数学:Excel表列序号