Update in identification if array is sorted or not
Here the identification process of the array that it is sorted or not was not properly constructed. Addition of the if statement will ensure that a sorted array with duplicate entries can be entered and identified.pull/758/head
parent
25e68800e4
commit
989ed51d6b
|
@ -52,13 +52,15 @@ int max=-2147483647;
|
|||
for(int i=0;i<size;i++){
|
||||
cin>>arr[i];
|
||||
// checking if input array is sorted or not
|
||||
if(arr[i]<max){
|
||||
if(i!=0){
|
||||
if(arr[i]<arr[i-1]){
|
||||
cout<<"Array not sorted";
|
||||
return 0;
|
||||
}else{
|
||||
max=arr[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
removeDuplicates(arr,size);
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue