Leetcode - Greatest Sum Divisible by Three
Leetcode - Excel Sheet Column Number

Leetcode - Sqrt(x)

violet posted @ 5 年前 in 算法 with tags Algorithm BinarySearch Golang , 351 阅读

https://leetcode.com/problems/sqrtx/

Implement int sqrt(int x).

Compute and return the square root of x, where x is guaranteed to be a non-negative integer.

Since the return type is an integer, the decimal digits are truncated and only the integer part of the result is returned.

Example 1:

Input: 4
Output: 2

Example 2:

Input: 8
Output: 2
Explanation: The square root of 8 is 2.82842..., and since 
             the decimal part is truncated, 2 is returned.

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
func mySqrt(x int) int {
    left := 1
    right := x
    var mid int
    for left <= right {
        mid = left + (right - left)/2
        tmp := mid * mid
        if tmp == x {
            return mid
        }
        if tmp < x {
            left = mid + 1
        } else {
            right = mid - 1
        }
    }
    if left * left > x {
        return left - 1
    }
    return left
}
Vip Model Delhi Esco 说:
3 年前

I am really grateful for this. I have got to learn a lot of things from this website.

Escorts in Chennai 说:
2 年前

Get Your Fill of Escorts with Our High-Class Escorts

Escort in Lucknow 说:
2 年前

There are loads of overall quite extraordinary equity through which we can have a bunches of incredible minutes.

Raipur Escorts 说:
2 年前

A responsibility of appreciation is for the epic data and pieces of data you have given here.

Escorts in Patna 说:
2 年前

I need to express gratitude for lovely blog offering to us.

Delhi Escort 说:
2 年前

What a thrilling post, you have pointed out some excellent points, I as well believe this is a superb website.

Bangalore Escort 说:
2 年前

This is your site that provides every important need, such very time to time I check your web post.

Bangalore Escort Ser 说:
2 年前

Wonderful Post, I highly appreciate those people who share some good information.

Escorts in Latur 说:
2 年前

I don't understand to see this post. Can you give me some conclusion of this site.

Bangalore Escorts Se 说:
2 年前

It is a tremendous and great way that have been supported from time to time in the recent things which have creat in the recent times.

Bangalore Call Girls 说:
2 年前

Hey Buddies, are you feel alone don't worry i am here to solve your every querry related to your life just click on my sites.

Electronic city Esco 说:
2 年前

This is your site that provides every important need, such very time to time I check your web post.

Electronic city Esco 说:
2 年前

To know more interesting things just click on my profile and enjoy your day.

Hyderabad Call Girl 说:
2 年前

http://gregoriolabatut.blogcanalprofesional.es/recordar-que-las-sociedades-inactivas-deben-presentar-cuentas-anuales-y-la-declaracion-de-is/#comment-30263

Escorts in Kochi 说:
2 年前

This is an incredible motivating article. I'm basically satisfied with your great work.

Bhabhi call girl pho 说:
2 年前

This is an incredible motivating article. I'm basically satisfied with your great work.

Delhi call girls 说:
2 年前

Its an amazing post and very appreciateI am very impressed with your post, in this post I have got a very good article which is an important information for me and if you want more such things then you can visit my website.

bangalore call girl 说:
大约 1 年前

Incredible tips and extremely straightforward. This will be extremely helpful for me whenever I have an opportunity to begin my blog.
This is a phenomenal site and I can not suggest you sufficiently all.

bangalore call girl 说:
大约 1 年前

I'm another client of this site so here I saw various articles and posts posted by this site,I inquisitive more interest in some of them trust you will give more data on this points in your next articles.

VIP Escorts Services 说:
大约 1 年前
You can be sure that our escorts will provide you with entertainment in every aspect possible. We offer an extensive range of services for all types of delightful moments. 
Sexy Vansika Call Gi 说:
大约 1 年前
We have girls who are trained to perform a variety of tasks, such as massage, sensual entertainment, and dancing. With us you will always find the best and the most coveted girls in Delhi.

 

Hindi Mein Chudai 说:
大约 1 年前
They have an impeccable record, good looking – which makes them very popular in the entertainment industry, and they are very much experienced that gives us a great leverage over other escort agencies.

 

Divya 说:
大约 1 年前
 
All of the above is information about escorts as it happens around the world. The information is based on the research I have done and are on this website so that people can be aware about it.
Antarvasna Audio Story || Sex Power Increase || Anjali Arora Sex video || Independent Sevrice in Goa ||
KOMAL 说:
大约 1 年前

To show how amazing this service is, one of the many testimonials given by a customer states: "I needed help with dressing up and going out in public.
Adult Whatsapp Group || Urfi Javed || Virgin Meaning In Hindi || Kiss Images ||

Adult Whatsapp Group 说:
大约 1 年前

A responsibility of appreciation is for the epic data and pieces of data you have given here.

noor 说:
大约 1 年前

[url=https://www.google.com]url[/url]
<a href="https://www.google.com">herf</a>
https://www.google.com

noor 说:
大约 1 年前

This will be by and large strong regions for around me whenever I get a huge chance to start my blog.

https://www.escortsdeals.com/call-girls/hyderabad
https://www.escortsdeals.com/call-girls/lucknow
https://www.escortsdeals.com/call-girls/chennai
https://www.escortsdeals.com/call-girls/surat
https://www.escortsdeals.com/call-girls/kolkata

Gurgaon Escorts 说:
大约 1 年前

Thank you for this wonderfull post! It has long been extremely helpful. I wish that you will carry on posting your knowledge with us thanks for sharing this post.

Gurgaon Escorts 说:
大约 1 年前

It felt very good to me and it made a lot of difference to me and it is true that I can believe it and it made me very happy and now https://www.escortsgurgaon.co.in/ I am very happy it really made me happy.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter