Search in a row wise and column wise sorted matrix

You have given row-wise and column-wise sorted 2d matrix and integer k, write a program to search k in 2d matrix, i.e. find whether k is present or not. Each row is sorted from left to right, and the first integer of each row is greater than the last integer of the previous row. Note: This is an excellent problem to learn problem solving binary search in a 2d matrix.

Inplace Rotate Square Matrix by 90 Degrees

Given an n x n 2D matrix, write a program to rotate the matrix by 90 degrees in anticlockwise direction. We should rotate matrix 90 degrees without using extra space. In other words, we have to perform rotation by modifying 2D matrix directly. Note: This is an excellent problem to learn problem-solving using nested loops and transpose of a matrix.

Spiral Traversal of Matrix

Given a 2-dimensional matrix, write a program to print matrix elements in spiral order. We can imagine spiral traversal as an ordered set of matrix segments with horizontal and vertical boundaries, where both boundaries are reduced by one at each step. Note: This is an excellent problem to learn problem-solving using iteration and recursion.

Subscribe to get weekly content on data structure and algorithms, machine learning, system design and oops.