Repository navigation
fix(searches): fix boundary safety and null checks in SaddlebackSearch - #7726
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.40% 82.41%
- Complexity 8481 8490 +9
=========================================
Files 846 846
Lines 26242 26245 +3
Branches 5128 5128
=========================================
+ Hits 21625 21629 +4
Misses 3828 3828
+ Partials 789 788 -1 ☔ 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.