You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Incorrect output for Binary Search when list contains duplicates #13840
Not a defect. binary_search([1,2,2,2,3], 2) returns 2, which is a valid index of the target. Classic binary search guarantees an index of a matching element, not the leftmost one. Closing as working as intended.
Activity
fix: TheAlgorithms#13840 - handle duplicate items correctly in binary…
Fix: binary_search returns first matcing index for array that contain…
Aditya-Singh27 commentedon Nov 7, 2025
I'll like to work on this issue , please assign it to me
Fix: Incorrect Binary Search output for duplicate elements (TheAlgori…
Merge branch 'Fix-Incorrect-Binary-Search-output-for-duplicate-elemen…
Fix: Return first index for binary search with duplicate elements (Th…
poorva-gupta commentedon Nov 30, 2025
hi, can you please assign this issue to me.
sneha-sharma17 commentedon Dec 19, 2025
Hi , I'd like to work on this issue.
I tested the current binary search implementation and confirmed that it returns
the last index when duplicates exist.
Before I proceed, can I confirm:
or
If approved, I will implement the fix along with test coverage.
Thanks!
fix: binary_search returns first index for duplicates
tusharynayaka commentedon Feb 28, 2026
Hi! I'd like to work on this bug. Could you please assign this issue to me? Thanks!
Fix binary search output for duplicates (Fixes TheAlgorithms#13840)
Fix binary_search to return first occurrence with duplicates
Fix binary search to return first occurrence for duplicates
Yashang-Parmar commentedon Jun 4, 2026
Hi! I'd love to solve this binary search duplicate bug. Could you please assign this issue to me?
mazhorin-coder commentedon Jun 5, 2026
Hi, I'd like to help with this issue.
cclauss commentedon Sep 10, 2026
Not a defect. binary_search([1,2,2,2,3], 2) returns 2, which is a valid index of the target. Classic binary search guarantees an index of a matching element, not the leftmost one. Closing as working as intended.