# Category Archives: Stack

## Find maximum in stack in O(1) without using additional stack

The task is to design a stack which can get the maximum value in the stack in O(1) time without using an additional stack. Examples:… Read More »

## Print leaf nodes in binary tree from left to right using one stack

Given a binary tree, the task is to print all leaf nodes of the given binary tree from left to right. That is, the nodes… Read More »

## Print the last k nodes of the linked list in reverse order | Iterative Approaches

Given a linked list containing N nodes and a positive integer K where K should be less than or equal to N. The task is… Read More »

## Sum of Bitwise-OR of all Submatrices

Given a NxN matrix, the task is to find the sum of bit-wise OR of all of its rectangular sub-matrices. Examples: Input : arr[][] =… Read More »

## Sum of bitwise AND of all submatrices

Given a NxN matrix, the task is to find the sum of bit-wise AND of all of its rectangular sub-matrices. Examples: Input : arr[][] =… Read More »

## Number of submatrices with OR value 1

Given a N*N binary matrix, task is to find the count of rectangular sub-matrices with OR value 1. Examples: Input : arr[][] = {{0, 0,… Read More »

## Number of submatrices with all 1s

Given a N*N matrix containing only 0s and 1s, the task is to count the number of submatrices containing all 1s. Examples: Input : arr[][]… Read More »

## Print Stack Elements from Bottom to Top

Given a stack s, the task is to print the elements of the stack from bottom to top, such that the elements are still present… Read More »

## Program to reverse a linked list using Stack

Given a linked list. The task is to reverse the order of the elements of the Linked List using an auxiliary Stack. Examples: Input :… Read More »

## Sum of minimum elements of all possible sub-arrays of an array

Given an array arr[], the task is to find the sum of the minimum elements of every possible sub-array of the array. Examples: Input: arr[]… Read More »

## Sum of maximum elements of all possible sub-arrays of an array

Given an array arr[], the task is to find the sum of the maximum elements of every possible sub-array of the array. Examples: Input: arr[]… Read More »

## Difference between Stack and Queue Data Structures

Stack A stack is a linear data structure in which elements can be inserted and deleted only from one side of the list, called the… Read More »

## Print the last k nodes of the linked list in reverse order | Recursive approach

Given a linked list containing N nodes and a positive integer k should be less than or equal to N. The task is to print… Read More »

## MakeMyTrip Interview Experience 2019

I applied for SSE position (Gurgaon Location) There were three rounds.. First round: Data Structures And Problem solving Level order traversal in spiral form Rotate… Read More »

## Check if moves in a stack or queue are possible or not

Given a binary array, where 1 denotes push operation and 0 denotes a pop operation in a stack or queue. The task is to check… Read More »