Repository navigation
fix(searches): fix boundary safety and null checks in SaddlebackSearch - #7726
hardikkaurani wants to merge 1 commit into
Conversation
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.
|
Hi @DenizAltunkapan, Could you please review this pull request when you have a moment? Summary of Changes
Test Results
Thank you for your time and consideration! |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #7726 +/- ##
============================================
- Coverage 82.23% 82.22% -0.01%
- Complexity 8402 8409 +7
============================================
Files 843 843
Lines 26140 26143 +3
Branches 5100 5100
============================================
Hits 21495 21495
- Misses 3853 3854 +1
- Partials 792 794 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
clang-format -i --style=file path/to/your/file.javaDescription
This pull request fixes boundary safety, null handling, visibility, and adds a convenience overload in
SaddlebackSearch:find(int[][] arr, int row, int col, int key), the check previously only testedrow < 0 || col >= arr[row].length. Passingrow >= arr.lengthwould trigger anArrayIndexOutOfBoundsExceptionwhen evaluatingarr[row]. Furthermore, negativecolvalues were not guarded against and would triggerArrayIndexOutOfBoundsExceptiononarr[row][col]. Addedrow >= arr.length,col < 0, andarr[row] == nullguards before accessing row contents.if (arr.length == 0)toif (arr == null || arr.length == 0)to avoidNullPointerExceptionand consistently throwIllegalArgumentException.static int[] findtopublic static int[] find.public static int[] find(int[][] arr, int key)that initiates search from the bottom-left corner (find(arr, arr.length - 1, 0, key)).SaddlebackSearchTestfor the convenience method, null arrays, out-of-bounds rows, negative column indices, and matrix with null rows.