Algorithm prefixAvg:
Input: An n-element array A
Output: Elements in array are unique
int A[n];
for(int i=0, i<n, i++){
for(int j=i+1; j<n; j++){
if(A[i]==A[j]){
return false;
}
}
}
return true
Answers
Answered by
1
prefix_avg = lambda arr: len(set(arr)) == len(arr)
for arr in [[1, 2, 3], [69, 999, 69]]:
print("Unique:", prefix_avg(arr))
Similar questions