Collecting Numbers
You are given an array that contains each number between exactly once. Your task is to collect the numbers from to in increasing order.
On each round, you go through the array from left to right and collect as many numbers as possible. What will be the total number of rounds?
Input
The first line has an integer : the array size.
The next line has integers : the numbers in the array.
Output
Print one integer: the number of rounds.
Constraints
Input:
Output:
On each round, you go through the array from left to right and collect as many numbers as possible. What will be the total number of rounds?
Input
The first line has an integer : the array size.
The next line has integers : the numbers in the array.
Output
Print one integer: the number of rounds.
Constraints
Input:
5
4 2 1 5 3
Output:
3
Solution:
We will take the input and check whether a smaller number appeared than it before if no then we will increase our ans.
0 Comments
If you have any doubts/suggestion/any query or want to improve this article, you can comment down below and let me know. Will reply to you soon.