Array

Arrays interview questions

Write code snippet for displaying matrix elements in a spiral order Create a matrix with alternating rectangles of O and X Find minimum element in rotated and sorted array Find an element in 2D sorted array or search target element in 2D sorted a…

Display matrix elements in a spiral order.

Problem :  We have to display elements of matrix in spiral order. For the given matrix mat(4x4).                  In Output order of elements should be  : 1  2  3  11  12  13  9  8  7  4   5  6  Note : solution proposed is valid for matrix of an…

Create a matrix with alternating rectangles of O and X .

Problem :   User will i nputs two numbers m and n and creates a matrix of size m x n (m rows and n columns) in which every elements is either X or 0.                             Solution :  Here outermost layer having X then O then again inner o…

Find minimum element in rotated and sorted array.

Problem : We have to find an element which is having lowest value in the given array which is sorted and rotated. FYI: This question was asked me in oracle interview.(All elements of the array are unique) what is sorted and rotated array ? Sorted a…

Load More
That is All