Help ASAP

Hey, i have a problem to solve that i give N numbers. If one number is bigger than the previous it creates a new stack. If a number is smaller than the top of one stack i must not create a new one. And i have to print how many stacks i have to create. For example:
Input:
12
20 19 22 20 21 40 30 15 20 100 120 90
Output:
6
Any ideas?
Last edited on
You don't actually have to store all the numbers - you only need to store the tops of the stacks. I recommend a std::set.
http://www.cplusplus.com/reference/set/set/
http://en.cppreference.com/w/cpp/container/set
Thank you!
Topic archived. No new replies allowed.