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

Bug at binary search #600

Open
mohanadtalat91 opened this issue Mar 19, 2022 · 2 comments
Open

Bug at binary search #600

mohanadtalat91 opened this issue Mar 19, 2022 · 2 comments

Comments

@mohanadtalat91
Copy link

Overflow will be happen at this line because if end=2147483647 & start=214 then the sum of start+end will be overflow.
So try to use the following formula to prevent overflow - - > mid=start+((end-start)/2)

@welcome
Copy link

welcome bot commented Mar 19, 2022

Thanks for opening your first issue here!

@Andyy-18
Copy link

Instead of using mid = (start+end)/2 , use mid = start+((end-start)/2).

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