Check if Array is Sorted Solution
unknown
c_cpp
2 years ago
275 B
9
Indexable
int isSorted(int n, vector<int> a) {
// Write your code here.
int sortedStatus = 1;
for(int i = 0; i< n - 1; i++){
if(a[i]> a[i + 1]){
sortedStatus = 0 ;
return sortedStatus;
}
}
return sortedStatus;
}
Editor is loading...
Leave a Comment