Tagged: data structure

Check Involuntary Matrix

“Check Involuntary Matrix” is a basic problem of matrix where we need to check whether given matrix is an involuntary matrix or not. There are basically three different types of matrix: Identity Matrix: An identity matrix is a square matrix of size N*N which have all the diagonal element as 1...

Check Identity Matrix

“Check Identity Matrix” is a problem of matrix, where we need to check whether given matrix is an identity matrix or not. There are basically three different types of matrix: Identity Matrix: An identity matrix is a square matrix of size N*N which have all the diagonal element as 1 and...

Multiply Two Matrix

“Multiply two matrix” is a standard operation which can be applied over two or more matrices. Here, we are given two matrices of dimension r1*c1 and r2*c2 respectively. Our task is to multiply the following matrices and store the result in resultant matrix. CONDITION : The two matrices can only be added if the...

blank

Transpose of a Matrix

“Transpose of a matrix” is a basic problem on matrix where we interchange the row and columns with each other. Here, we are given a matrix of size N*M and our task is to find the transpose of the matrix by interchanging the row and columns. The resultant matrix will...

blank

Add Two Matrix

“Add Two Matrix” is a basic operation which can be applied over two or more matrices. Here, we have given two matrices of dimension N*M and our task is to add the following matrices and store the result in resultant matrix. CONDITION: The dimensions of the matrices to be added...

blank

Merge Overlapping Intervals

“Merge Overlapping Intervals” is a standard application of stack data structure. Here, we have given set of intervals and our task is to merge all overlapping intervals and then print the resultant non-overlapping intervals. Example: The set of intervals are: (1,4) , ( 2,5) , (7,8) , ( 6,9). After merging...

blank

Implement Queue Using Stacks

“Implement Queue using Stacks” is a classic interview problem based on stack and queue data structures. Here, we have given two stacks and our task is to implement queue using these two stack.  Stack contains basically two operations, including:  push and pop. To implement queue using given two stacks, we need to perform some...

blank

Next Greater Element

“Next Greater Element” is a classic interview problem based on stack data structure. Here, we have given an array with ‘n’ elements. Our task is to print next greater element of each element of an array. If there is no greater element for any element in an array, simply print...

blank

Check for balanced parentheses

“Check for balanced parentheses” is one of an ideal application of stack data structure. Here, we have given a parentheses string and our aim is to check whether the given string is balanced parentheses string or not.  Balanced parentheses strings are those strings who have closing parentheses like }, ], ) for each...