当前位置:网站首页>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;
}
边栏推荐
- 3.1 Monte Carlo Methods & case study: Blackjack of on-Policy Evaluation
- 4G module at command communication package interface designed by charging pile
- 使用密钥对的形式连接阿里云服务器
- Flutter 退出当前操作二次确认怎么做才更优雅?
- CV learning notes alexnet
- My 4G smart charging pile gateway design and development related articles
- My notes on the development of intelligent charging pile (III): overview of the overall design of the system software
- LeetCode - 673. Number of longest increasing subsequences
- LeetCode 面试题 17.20. 连续中值(大顶堆+小顶堆)
- Leetcode-106:根据中后序遍历序列构造二叉树
猜你喜欢

Open Euler Kernel Technology Sharing - Issue 1 - kdump Basic Principles, use and Case Introduction

CV learning notes - camera model (Euclidean transformation and affine transformation)

Working mode of 80C51 Serial Port

1. Finite Markov Decision Process

Flutter 退出当前操作二次确认怎么做才更优雅?

LeetCode - 706 设计哈希映射(设计) *

Connect Alibaba cloud servers in the form of key pairs

Leetcode - 933 number of recent requests

LeetCode - 5 最长回文子串

CV learning notes - image filter
随机推荐
20220608其他:逆波兰表达式求值
LeetCode - 1670 设计前中后队列(设计 - 两个双端队列)
About windows and layout
CV learning notes ransca & image similarity comparison hash
Retinaface: single stage dense face localization in the wild
Modelcheckpoint auto save model
Matplotlib drawing
LeetCode - 5 最长回文子串
(2) New methods in the interface
20220603数学:Pow(x,n)
Opencv notes 20 PCA
3.2 Off-Policy Monte Carlo Methods & case study: Blackjack of off-Policy Evaluation
QT self drawing button with bubbles
Application of external interrupts
Anaconda安装包 报错packagesNotFoundError: The following packages are not available from current channels:
Label Semantic Aware Pre-training for Few-shot Text Classification
20220601数学:阶乘后的零
Simulate mouse click
El table X-axis direction (horizontal) scroll bar slides to the right by default
3.3 Monte Carlo Methods: case study: Blackjack of Policy Improvement of on- & off-policy Evaluation