From 2f3ebd36f873746b9f17d571201dd5bb873bdf4c Mon Sep 17 00:00:00 2001 From: sumanth <58482399+sumanth00100@users.noreply.github.com> Date: Fri, 10 Apr 2026 20:31:48 -0400 Subject: [PATCH 1/2] Implemented 2Dmatrix and search in sorted Array --- 2dMatrix.java | 26 ++++++++++++++++++++++ search-in-rotated-sorted-array.java | 34 +++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 2dMatrix.java create mode 100644 search-in-rotated-sorted-array.java diff --git a/2dMatrix.java b/2dMatrix.java new file mode 100644 index 00000000..6ae7f58c --- /dev/null +++ b/2dMatrix.java @@ -0,0 +1,26 @@ +// Time Complexity : +// Space Complexity : +// Did this code successfully run on Leetcode : Yes +// Any problem you faced while coding this : No +class Solution { + public boolean searchMatrix(int[][] matrix, int target) { + int matrixLen = matrix[0].length ; + int high = (matrix.length * matrixLen)-1; + int low = 0; + while(low<=high){ + int mid = low + (high-low)/2; + int m = mid/matrixLen; + int n = mid%matrixLen; + if(matrix[m][n]==target){ + return true; + } + if(matrix[m][n]= nums[low]){ + if(target>=nums[low] && targetnums[mid]){ + low = mid +1; + } + else { + high = mid -1; + } + } + } + return -1; + } +} \ No newline at end of file From 6fa9b24946774313695165045a457ecd6143f221 Mon Sep 17 00:00:00 2001 From: sumanth <58482399+sumanth00100@users.noreply.github.com> Date: Fri, 10 Apr 2026 20:32:25 -0400 Subject: [PATCH 2/2] Implemented 2Dmatrix and search in sorted Array --- 2dMatrix.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/2dMatrix.java b/2dMatrix.java index 6ae7f58c..274d9cb4 100644 --- a/2dMatrix.java +++ b/2dMatrix.java @@ -1,5 +1,5 @@ -// Time Complexity : -// Space Complexity : +// Time Complexity : O(log(m*n)) +// Space Complexity : O(1) // Did this code successfully run on Leetcode : Yes // Any problem you faced while coding this : No class Solution {