Add generic and sorted 2D matrix search utilities#7217
Open
GziXnine wants to merge 16 commits intoTheAlgorithms:masterfrom
Open
Add generic and sorted 2D matrix search utilities#7217GziXnine wants to merge 16 commits intoTheAlgorithms:masterfrom
GziXnine wants to merge 16 commits intoTheAlgorithms:masterfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #7217 +/- ##
============================================
+ Coverage 79.09% 79.15% +0.06%
- Complexity 6973 7005 +32
============================================
Files 783 785 +2
Lines 22950 23017 +67
Branches 4512 4536 +24
============================================
+ Hits 18152 18219 +67
Misses 4077 4077
Partials 721 721 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…rays, and null comparator
Contributor
Author
|
Hi @DenizAltunkapan, @yanglbme, @alxkm, I noticed that my pull request (#7217) has all checks passed, but it still cannot be merged. Thank you for your time and guidance! |
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.javaSummary
This PR adds two reusable 2D matrix search utilities under
com.thealgorithms.matrix.SearchSortedMatriximplements Saddleback (“staircase”) search for matrices whose rows and columns are sorted in ascending order, providing an efficientO(m+n)membership check without flattening.SearchMatrixprovides a general-purposecontainsmethod for arbitraryT[][]matrices with no ordering assumptions, using a straightforward linear scan.Details
SearchSortedMatrixnull/empty matrices.O(m+n), spaceO(1).SearchMatrixT[][].Objects.equals.O(m*n), spaceO(1).Tests
Adds unit coverage for both algorithms:
SearchSortedMatrixTestSearchMatrixTestThese tests cover typical found/not-found cases and edge conditions (null/empty input, jagged matrices, and null rows/elements where applicable).
Closes #6622