Matrix

Search a 2D Matrix

Write an efficient algorithm that searches for a value in an m x n 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

Input: 
matrix = [[1,3,5,7],[10,11,16,20],[23,30,34,60]], target = 3

Output: true
class Solution {
	public boolean searchMatrix(int[][] matrix, int target) {
		int start = 0;
		int last = matrix[0].length - 1;

		while (last >= 0 && start < matrix.length) {
			if (matrix[start][last] < target)
				start++;
			else if (matrix[start][last] > target)
				last--;
			else
				return true;
		}

		return false;
	}
}

Flood Fill

Max Area of Island

Reshape the Matrix

Pascal's Triangle

Boundary traversal of matrix

Spirally traversing of matrix

Adding two matrices

Sum of upper and lower triangles

Matrix Multiplication

Transpose without extra space

Rotate by 90 degree

Reversing the columns of a Matrix

Boolean Matrix

Make matrix beautiful

Unique rows in boolean matrix

Last updated