A set must pass on these three conditions:
– All values are positive
– Sorted
– Non-duplicates
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool isSet(int arr[],int n){ | |
int i=0; | |
while(i<n){ | |
if(arr[i]<0) | |
return false; | |
if(i==0){ | |
i++; | |
continue; | |
} | |
if(arr[i]<=arr[i-1]) | |
return false; | |
i++; | |
} | |
return true; | |
} |