Quote Originally Posted by rmmstn View Post
Well my logic was that, if neither counter is (n-1) in the end, that would mean that the array is not increasing/decreasing, but I think I didn't understand the task right. I believe 1, 2, 2, 3, 4 is still a sorted array since the elements are in increasing order (right?). 1, 1 ,1 is unsorted (because they're all equal?) and 1, 1, 0 is sorted because the elements are decreasing. Is this logic right? Does it matter if the elements are repeated?
It really just depends on the convention you want to go with. I think hamster_nz's approach is a good one, although I would recommend encoding those return values as enums/defines so that the usage is a little more intuitive.