Print Matrix in Spiral Order

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

Find row with maximum number of 1s

Given a boolean 2D array, where each row is sorted. Find the row with the maximum number of 1s. This is an excellent matrix problem that can be solved in linear time complexity. The best part is — we are using the sorted order property and nested loops to improve the solution over the binary search approach.

Rotate a matrix by 90 degrees

Given an n x n 2D matrix representing an image, rotate the image by 90 degrees in an anticlockwise direction.

Sorting Algorithms: Bubble Sort, Selection Sort and Insertion Sort

Sorting algorithms are the most fundamental problems to study in data structure and algorithms. But the critical question is - why we learn the design, code, and analysis of the sorting algorithms? Explore and Think!

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