Question: One by one pop all characters from stack and put them back to string. 3 . Reverse a number using stack - Given a number,
One by one pop all characters from stack and put them back to string.
Reverse a number using stack Given a number, write a program to reverse this number using stack.
Examples:
Input :
Output :
Input :
Output :
Notes on problem
The idea to do this is to extract digits of the number and push the digits on to a stack. Once all of the digits of the number are pushed to the stack, we will start popping the contents of stack one by one and form a number.
As stack is a LIFO data structure, digits of the newly formed number will be in reverse order.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
