Java icon indicating copy to clipboard operation
Java copied to clipboard

Add Search a 2D Matrix algorithm

Open AHVSSATHVIK opened this issue 3 months ago • 2 comments

Description

This pull request adds the Search a 2D Matrix algorithm to the directory
src/main/java/com/thealgorithms/matrix/.

This algorithm solves the well-known problem where each row of the matrix is sorted,
and the first element of each row is greater than the last element of the previous row.
A binary search is applied on the virtual 1D representation of the matrix to achieve
O(log(m*n)) time complexity.

A detailed explanation of the problem can be found here:
https://leetcode.com/problems/search-a-2d-matrix/

This implementation includes:

  • Clean binary search logic
  • JavaDoc-style documentation
  • Proper placement within the matrix package

Type of Change

  • [x] New Algorithm (non-breaking addition)
  • [x] Enhancement to the matrix category

Checklist

  • [x] I have read CONTRIBUTING.md.
  • [x] This pull request is all my own work.
  • [x] File name follows PascalCase.
  • [x] Function and variable names follow Java coding conventions.
  • [x] Added the required URL reference in the JavaDoc comment.
  • [x] Code is formatted with clang-format as required.

AHVSSATHVIK avatar Nov 25 '25 06:11 AHVSSATHVIK

Codecov Report

:x: Patch coverage is 0% with 18 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 78.43%. Comparing base (1c6026e) to head (3018106).

Files with missing lines Patch % Lines
.../java/com/thealgorithms/matrix/Search2DMatrix.java 0.00% 18 Missing :warning:
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #7114      +/-   ##
============================================
- Coverage     78.50%   78.43%   -0.07%     
+ Complexity     6752     6751       -1     
============================================
  Files           759      760       +1     
  Lines         22402    22420      +18     
  Branches       4400     4403       +3     
============================================
- Hits          17587    17586       -1     
- Misses         4109     4127      +18     
- Partials        706      707       +1     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

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

codecov-commenter avatar Nov 25 '25 06:11 codecov-commenter

i have made the changes

AHVSSATHVIK avatar Nov 25 '25 13:11 AHVSSATHVIK