From 0c620cfe3213741422df6b45609f0ac27b9c4932 Mon Sep 17 00:00:00 2001 From: bilwa496 <66560100+bilwa496@users.noreply.github.com> Date: Thu, 27 Oct 2022 01:43:52 +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. --- Cpp/search_2d_matrix.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Cpp/search_2d_matrix.cpp diff --git a/Cpp/search_2d_matrix.cpp b/Cpp/search_2d_matrix.cpp new file mode 100644 index 0000000..02478a6 --- /dev/null +++ b/Cpp/search_2d_matrix.cpp @@ -0,0 +1,22 @@ +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