Is it possible to check if a vector has increasing sequence in it? Given that it’s a random vector? C++ | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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?

27th Apr 2022, 8:25 PM
Annei ❤️
Annei ❤️ - avatar
4 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
28th Apr 2022, 12:54 AM
Arsenic
Arsenic - avatar
+ 1
Annei, Sorry for a silly confirmation, but what is increasing sequence here? And by vector, you meant the C++ container or other terms?
27th Apr 2022, 9:04 PM
Ipang
+ 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.
27th Apr 2022, 9:11 PM
Annei ❤️
Annei ❤️ - avatar
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.
27th Apr 2022, 8:50 PM
Annei ❤️
Annei ❤️ - avatar