Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Last updated: Aug 2, 2022

Stack

When talking about Data Structures and algorithms associated with them, we need to talk about Stacks. A stack is a linear data structure, which follows a particular order in which operations can be performed. These operations may be FILO (First In Last Out) or LIFO(Last In First Out). Stacks can be implemented using arrays and linked lists manually, while languages like C++, Java, and Python have built-in classes, STLs, and libraries to implement them. In this category, we will look into all operations and problems related to Stacks.
Stack in Python (LIFO Queue) EASY
Stack is an important data structure that is used in all programming languages. This article describes a stack in Python(LIFO Queue), in particular.
Difference Between Stack And Queue Data Structures EASY
Stacks and queues are fundamental data structures. Stacks follow LIFO, while queues adhere to FIFO. In this article, Understand their differences and usage in programming.
Python Stack Using Doubly Linked List MEDIUM
In this blog, we will see how to implement the stack data structure using a doubly-linked list in Python.
Difference Between Stack and Tree
In this blog, we'll go through the definitions of stack and tree, as well as the differences between the two.
Difference between Array, Queue and Stack MEDIUM
In this article, we will discuss the difference between Array, Queue, and Stack in detail.
Infix, Postfix, and Prefix Conversion EASY
This article discusses infix, Postfix, and Prefix conversion. Read the algorithm, examples, advantages, and disadvantages.
Peek() Operation in Stack EASY
This article demonstrates the peek operation in stack and its algorithm with its implementation.
Expression Evaluation Using Stack MEDIUM
Often, a program for expression evaluation using stack is asked in the coding rounds of interviews. This article discusses the solution to this problem.
What is Stack in C EASY
In this article, we will learn about the stack data structure, its operations, time complexity, types, applications & implementation using arrays & linked lists.
Mergeable Stack EASY
In this blog, we will discuss the logic of how to create a mergeable stack and display them and their implementation in C++.
Implement Stack using a Singly Linked List EASY
This article covers the implementation of a stack using a singly linked list with examples and its C++ code.
Author Spider
3 upvotes
Implement Stack Using a Doubly-Linked List MEDIUM
This article covers the implementation of a stack using a doubly-linked list with examples and its C++ code, and its time and space complexity.
Remove Adjacent Duplicates MEDIUM
This article discussed one of the most elementary problems based on stack, i.e., Removing Adjacent Duplicates along with its implementation.
Delete Middle Element Of The Stack EASY
In this article, we’ll see how to delete middle element of a stack without using any additional data structure and implementation in C++ language.
Program to Insert an Element at the Bottom of a Stack MEDIUM
This article will brief you on how to insert an element at the Bottom of a Stack.
Reversing a Stack MEDIUM
In this blog we will discuss different method to Reverse a stack along with codes in Java. Read on to learn how to reverse a stack.
Next Greater/Smaller Element using a Monotonic Queue MEDIUM
This blog covers an interview problem: find the Next greater/smaller element using a monotonic queue using various approaches along with the Java code.
Author Riya
1 upvote
Add Two Numbers Represented by Stacks MEDIUM
This blog has information on how to add two numbers represented by stacks and how to implement it.
Python Program to Reverse a Stack EASY
This blog will cover the question to reverse a Stack and discuss its Time and Space complexity along with its implementation in Python language.
Two stacks in an array EASY
In this blog, we will discuss the approach to store the elements of two stacks in an array.
Iterative Tower of Hanoi MEDIUM
In the following article, we discuss an iterative approach to the popular Tower Of Hanoi problem with its implementation in C++, Java, Python, and its complexities.
Design a Minimum Stack MEDIUM
This blog discusses the solution to the problem of minimum stack in which we have to return the smallest element of a stack. Read the blog to learn more!
Trapping Rainwater MEDIUM
The following article discusses the popular Trapping Rainwater problems along with its possible solutions form most intuitive to most optimal ones with their implementations.
Count Array Elements having at Least One Smaller Element on its Left and Right Side MEDIUM
This article explains the solution to the problem of counting array elements having at least one smaller element on its left and right side.
Minimize the Length of a given String by Removing Subsequences Forming Valid Parenthesis HARD
In this article, we’ll learn how to solve an interesting problem i.e. Minimize the Length of a given String by Removing Subsequences Forming Valid Parenthesis along with its implementation.
Diagonal Traverse ii MEDIUM
In this blog, we will build logic for the Diagonal traversal of integers and see the various implementations of this problem.
Reverse level order traversal EASY
This article will make you learn about the reverse level order traversal in the tree data structure. In the end, it will include some of the FAQs.
Minimize a Binary String by Repeatedly Removing Even-Length Substrings of the Same Characters HARD
This blog will cover the question to minimize a binary string by repeatedly removing even length substrings of the same characters and discussing its Time and Space complexity.
Minimize a String By Removing All Occurrences of Another String
This article will discuss the Minimize a string by removing all occurrences of another string problem and various ways to solve this problem, from the brute force approach to the efficient approach.
Print Stack Elements from Top to Bottom EASY
In this article, we will see the common stack problem of printing the stack elements from top to bottom in java, c++, and python with time and space complexities.
Smallest String Obtained By Removing All Occurrences of 01 and 11 from the Binary String HARD
This article discusses the Problem of obtaining the smallest string possible by removing all occurrences of 01 and 11 from a binary string along with its implementation.
Count of Strings that do not Contain Arc Intersection MEDIUM
This article explains the solution to the problem to find the count of strings that do not contain arc intersections along with the implementation in C++.
Minimize Length of a String by Removing Pairs of Consecutive Increasing or Decreasing Digits HARD
This article discusses the Problem of  Minimising Length of a String by Removing Pairs of Consecutive Increasing or Decreasing Digits
Special Stack Data Structure Design and Implementation MEDIUM
This blog is related to the famous Stack Problem "Special Stack Data Structure," which contains an additional getMin() operation.
Application of Stack in Data Structure EASY
In this article, we will cover Stack in Data Structure in detail, including the application of stack, its advantages and disadvantages.
Number of NGEs to the right
In this blog, we will discuss the approach to print the number of next greater elements to the right of the given index element.
K stacks in a single array EASY
In this blog, we will discuss the logic of how to implement k stacks in a single array and the code of it in c++.
Largest Rectangle in Histogram EASY
In this article, we’ll learn how to find the largest rectangle in a histogram.
Reverse a number using Stack EASY
In this article, we will discuss a very interesting problem: we have to reverse the decimal number given to us using the stack data structure.
Reverse a Linked List using Stack MEDIUM
This article covers the approach of reversing a linked list using stack data structure with complete explanation and its implementation in C++.
Count Subarrays for every Array Element in Which they are the Minimum MEDIUM
In this blog, we will discuss the problem of counting subarrays for every array element in which they are the minimum.
Check if stack elements are pairwise consecutive EASY
This article explains the problem “check if stack elements are pairwise consecutive” with an example.
Distance from Next Greater Element MEDIUM
In this article, we will discuss the problem distance from next greater element along with its implementation.
Convert Given Binary String S to all 1s by Changing all 0s to 1s in Range [i+1, i+K] if S[i] is ‘1’ MEDIUM
https://www.codingninjas.com/codestudio/library/convert-given-binary-string-s-to-all-1s-by-changing-all-0s-to-1s-in-range-i-1-i-k-if-s-i-is-1
Count of Groups of Consecutive 1s in a given Binary String MEDIUM
This blog will discuss the problem named count of groups of consecutive 1s in a given binary string with an example and implementation.
Check if a String Consisting Only of a, b, c can be made Empty by Removing Substring “abc” Recursively MEDIUM
This blog will cover the question to check if a string consisting only of a, b, c can be made empty by removing substring “abc” recursively and discussing its Time and Space complexity.
Maximum Range Length such that A[i] is Maximum in the given Range for all i from [1, N] MEDIUM
In this article, we will discuss the problem of Maximum range length such that A[i] is maximum in the given range for all i from [1, N] along with its implementation.
Check if a String can be Emptied by Removing all Subsequences of the Form “10” MEDIUM
This article discusses how to check if a string can be emptied by removing all the subsequences of the form "10" along with its implementation in java language.
Lexicographically Smallest String MEDIUM
This blog will discuss the problem to find the lexicographically smallest K-length subsequence from a given string in C++, Java, and Python language along with the time and space complexity.
Reverse an Array using Stack EASY
This blog will cover the question to reverse an array using a Stack and discuss its Time and Space complexity along with its implementation in java language.
Count of subarrays starting or ending at an Index i such that arr[i] is maximum in the subarray MEDIUM
This article will discuss the solution to count subarrays starting or ending at index i such that arr[i] is maximum in the subarray.
Check if an array is stack sortable EASY
In this blog, we will use a stack to check if an array is sortable or not. The elements of the array will get sorted using pop and push operation on stack.
Reverse Words in a Given String
This article revolves around the question which says Reverse words in a given String. We discuss how to approach the problem and solve it in Java
Maximum product of indexes of next greater on left and right EASY
In this article, we will discuss a very interesting problem in which we have to calculate the maximum product of indexes of the next greater on left and right among all the given elements.
Maximize the Product of the Subarray Sum with its Minimum Element MEDIUM
This article will brief you on how to Maximize the product of the subarray sum with its minimum element.
Daily Temperatures MEDIUM
This article explains how to find the number of days remaining for the next day with higher temperatures along with its implementation in JAVA.
Minimum Removals to Make Valid Parentheses MEDIUM
This blog will cover the approach to an interesting problem, Minimum removals to make valid parentheses with examples, and C++ code.
Author Spider
0 upvotes
Online Stock Span MEDIUM
This article will brief you on finding the online stack span for each day of stock given as a stream of array elements.
Create Maximum Number MEDIUM
In this article, we will discuss a problem involving applications of topics like arrays, merge sort, and stacks.
Check if a queue can be sorted into another queue using a stack
This article will solve a question related to the topic of queue and stack data structure.
Stack that supports getMin() in O(1) time and O(1) extra space
In the blog, we will discuss the problem of defining a stack that supports getMin() in O(1) time and O(1) extra space.
How To Sort A Stack Using Recursion? MEDIUM
Learn how to sort a stack using recursion in this step-by-step guide. Master the recursive approach to efficiently organize stack elements, gaining valuable programming skills along the way.
Check if an array is stack permutation of other MEDIUM
In this article, we will discuss a very interesting problem: to check if an array is stack permutation of other or not.
Next Greater Frequency Element
This blog discusses the approach to find for each element,the next greater frequency element on the right of it.
Stack Operations in Data Structure EASY
In this article, we will explore the stack operations push, pop, peek, isEmpty, and isFull with the implementation of stack both using array and linked list.