• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests
March 25, 2024 |800 Views
PROBLEM OF THE DAY : 24/03/2024 | Insert an Element at the Bottom of a Stack
Description
Discussion

Welcome to the daily solving of our PROBLEM OF THE DAY with Yash Dwivedi. We will discuss the entire problem step-by-step and work towards developing an optimized solution. This will not only help you brush up on your concepts of Satck but also build up problem-solving skills.

In this problem, we are given a stack st of n integers and an element x. You have to insert x at the bottom of the given stack.

Note: Everywhere in this problem, the bottommost element of the stack is shown first while printing the stack.

Example :

Input:
n = 5
x = 2
st = {4,3,2,1,8}
Output:
{2,4,3,2,1,8}
Explanation:
After insertion of 2, the final stack will be {2,4,3,2,1,8}.

Give the problem a try before going through the video. All the best!!!
Problem Link: https://www.geeksforgeeks.org/problems/insert-an-element-at-the-bottom-of-a-stack/1
Solution IDE Link: https://ide.geeksforgeeks.org/online-cpp14-compiler/e60345b0-3d94-4cce-94c7-b2d9f1330efb

Read More