Skip to content

Conversation

ARES2525
Copy link

@ARES2525 ARES2525 commented Oct 5, 2025

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized it.
  • All filenames are in PascalCase.
  • All functions and variable names follow Java naming conventions.
  • All new algorithms have a URL in their comments that points to Wikipedia or other similar explanations.
  • All new code is formatted with clang-format -i --style=file path/to/your/file.java

Pull Request Description

What does this PR do?
Adds implementations for the "Search a 2D Matrix" problem (both variations) commonly found on LeetCode (#74 and #240). These algorithms are added under src/main/java/com/thealgorithms/matrix to provide useful matrix search solutions.

Why is this needed?
The current matrix directory lacks solutions for these frequently asked interview problems. Adding them will help learners and contributors understand efficient ways to search in 2D matrices.

Changes made:

  • Implemented Search2DMatrix.java containing methods for both matrix search variations.
  • Code follows Java naming conventions and project formatting guidelines.
  • Added relevant LeetCode URLs and explanations in comments for educational purposes.

Related Issue:
Fixes #6622

@codecov-commenter
Copy link

codecov-commenter commented Oct 5, 2025

Codecov Report

❌ Patch coverage is 81.25000% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.75%. Comparing base (a0b6c52) to head (4b2e5ad).

Files with missing lines Patch % Lines
.../java/com/thealgorithms/matrix/Search2DMatrix.java 81.25% 3 Missing and 3 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #6639      +/-   ##
============================================
+ Coverage     75.74%   75.75%   +0.01%     
- Complexity     5765     5774       +9     
============================================
  Files           701      702       +1     
  Lines         19757    19789      +32     
  Branches       3831     3837       +6     
============================================
+ Hits          14964    14991      +27     
- Misses         4214     4217       +3     
- Partials        579      581       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

- Added JUnit tests covering both variations of 2D matrix search.
- Tests validate correctness for typical inputs and edge cases.
- Helps increase code coverage and ensures algorithm correctness.
@ARES2525 ARES2525 closed this Oct 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE REQUEST] : Add Search a 2D Matrix in src/main/java/com/thealgorithms/matrix.

2 participants