0
Is it possible to check if a vector has increasing sequence in it? Given that itâs a random vector? C++
^^ Would that be possible? From all the research I see on Vectors, iâve noticed that checking to see if a vector has increasing sequence or not is usually done on ordered sets. How?
5 Answers
+ 3
According to me, a vector will always have an increasing subsequence with the only exception being when it is sorted in non-increasing order ( 5 4 4 2 1 for example ).
Now the question boils down to finding whether the vector given to you is in non-increasing order or not, and that can easily be done using std::is_sorted ()
https://en.cppreference.com/w/cpp/algorithm/is_sorted
+ 1
Annei,
Sorry for a silly confirmation, but what is increasing sequence here?
And by vector, you meant the C++ container or other terms?
+ 1
No it is literally no problem! I meant like i wanted to check if a vector like this: 3 7 4 5 6 8 8 8 has an increasing consecutive order, and it does because â4 5 6â are increasing amd consecutive.
0
Thank you! I would not want to sort them at all, but rather chrck to see if there is a sequence in the particular set.