Repository navigation
fix(searches): fix out-of-bounds in single-row and single-column in BinarySearch2dArray - #7724
Open
hardikkaurani wants to merge 1 commit into
Open
hardikkaurani wants to merge 1 commit into
hardikkaurani wants to merge 1 commit into
Conversation
…inarySearch2dArray
hardikkaurani
requested review from
DenizAltunkapan,
alxkm and
yanglbme
as code owners
November 2, 2026 05:58
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
Contributor
Author
|
Hi @DenizAltunkapan, Could you please review this pull request when you have a moment? Summary of Changes
Thank you for your time and consideration! |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #7724 +/- ##
=========================================
Coverage 82.23% 82.23%
- Complexity 8402 8405 +3
=========================================
Files 843 843
Lines 26140 26142 +2
Branches 5100 5101 +1
=========================================
+ Hits 21495 21497 +2
- Misses 3853 3854 +1
+ Partials 792 791 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
clang-format -i --style=file path/to/your/file.javaDescription
This pull request fixes out-of-bounds errors on single-row and single-column matrices, and exposes
binarySearchas a public method inBinarySearch2dArray:binarySearch(int[][] arr, int target), whenrowCount == 1, the helperbinarySearch(arr, target, 0, 0, colCount)was called withcolCountinstead ofcolCount - 1. Because the helper uses an inclusive upper bound (colStart <= colEnd), searching for an element greater thanarr[0][colCount - 1]causedmidIndexto equalcolCount, triggering anArrayIndexOutOfBoundsException. Updated to passcolCount - 1.colCount == 1,midColis 0. AccessingmidCol - 1threwArrayIndexOutOfBoundsException: Index -1 out of bounds for length 1. Added an edge-case guard returning{-1, -1}whencolCount == 1after checkingmidCol.binarySearch(int[][] arr, int target)from package-private topublic static.