问题
How to check whether an array or a linked list is sorted or not given a set of numbers using c++?. Is there a function available to check that?
回答1:
Simply use std::is_sorted something like:
if (std::is_sorted(std::begin(linked_list), std::end(linked_list)) {
//...
}
回答2:
Check this stack overflow link hope you get it your answer.
How do I code a function to test if a linked list is sorted
来源:https://stackoverflow.com/questions/35867423/how-to-check-whether-a-linked-list-is-sorted-or-not-using-c