Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Leetcode69 sqrt(x)有个小问题~ #2

Open
Chuncheng666 opened this issue May 3, 2018 · 1 comment
Open

Leetcode69 sqrt(x)有个小问题~ #2

Chuncheng666 opened this issue May 3, 2018 · 1 comment

Comments

@Chuncheng666
Copy link

首先我用的是Visual Studio 2015,之前觉得这题很水,直接写了一个for(int i=0;i<=x;i++)的循环,然后超时,来看了柳神的代码,发现可以使用二分法,我也根据你的long来的,但是发现还是卡住不出结果,所以我就单步调试了一下,发现mid和left都变成负的很大的数字了,看着像是溢出,这时候我把mid改成long long类型,就迅速的返回了结果~ 还有一个地方在最外面定义了long mid =0,循环里面又定义long mid啦~~

@typochecker
Copy link

sizeof(long int)=sizeof(int)=sizeof(long)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants