binary-gap: infinite loop on negative input
Nobody has claimed this yet.
Assessment
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Newbie friendliness
- 78/100
Research direction
Start by reading binary-gap/solution.py and exercise binary_gap with a negative input to confirm the non-terminating behavior. Add the requested guard or early return, then verify that negative inputs terminate and the existing positive-input behavior remains unchanged.
Written by the indexing model from the issue text.
Description
`binary_gap` causes an infinite loop when passed a negative integer. Python's arbitrary-precision right-shift of a negative number never reaches `0`, so the while loop never terminates.
File: `binary-gap/solution.py`
Impact: Latent bug masked by LeetCode's constraint `1 <= n <= 10^9`. Would hang if constraints were relaxed to include negative integers.
Suggested fix: Add an early return or guard for `n <= 0`.
- Dominant language
- Python
- Stars
- 0
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from benthomasson/leetcode-implementations
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 88/100
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 86/100
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 78/100
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 88/100
All issues in benthomasson/leetcode-implementations
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100