From bff012dd9bf99f7e6dad844ce5429ac5ef32722e Mon Sep 17 00:00:00 2001 From: bilwa496 <66560100+bilwa496@users.noreply.github.com> Date: Wed, 26 Oct 2022 23:46:58 +0530 Subject: [PATCH] Created search_2d_matrix.cpp Write an efficient algorithm that searches for a value target in an m x n integer matrix matrix. This matrix has the following properties: Integers in each row are sorted from left to right. The first integer of each row is greater than the last integer of the previous row. --- search_2d_matrix.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 search_2d_matrix.cpp diff --git a/search_2d_matrix.cpp b/search_2d_matrix.cpp new file mode 100644 index 0000000..03637b6 --- /dev/null +++ b/search_2d_matrix.cpp @@ -0,0 +1,21 @@ +class Solution { +public: +bool searchMatrix(vector& matrix, int target) { + + int rowsize=matrix.size(); + int colsize=matrix[0].size(); + int i=0, j=colsize-1; + while(i>=0 && i=0 && jtarget) + j--; + else if(arr