Coders Packet

Remove k digits in C++

By Muskan Chaturvedi

In this problem we are supposed to remove k digits so that the resulting integer is the smallest possible integer after removing k digits.

function image

1)In this stack data structure is used which will be storing the digits that satisfies the if else conditions and when the string is reached at its end ,the digits from the stack are popped and stored in a string. 

PUSH-used to push a digit inside the stack.

POP-used to take a element out of the stack.

TOP-used to get the top most element inside the stack.

main function

2) As stack follows last in first out(LIFO) principle so the digits in the stack will be coming out in the LIFO order and to make the order correct .Reverse function is used as the digits will be in reverse order when they are popped.

Download Complete Code

Comments

No comments yet

Download Packet

Reviews Report

Submitted by Muskan Chaturvedi (Muskan01)

Download packets of source code on Coders Packet