How to compare the input and the Top of stack? | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 1

How to compare the input and the Top of stack?

if top value < input value, then input value allowed get into the stack

8th Apr 2018, 4:44 AM
Muhammad Rifqi
Muhammad Rifqi - avatar
2 Réponses
+ 4
Use the "Peek" Method to get the value on top of the stack and compare using "if". If input is greater use the "Push" method to add the value to the stack.
9th Apr 2018, 11:20 AM
Rusty.Metal
+ 1
thanks!!
9th Apr 2018, 11:22 AM
Muhammad Rifqi
Muhammad Rifqi - avatar