Minimum maximum in Array

PHOTO EMBED

Thu Sep 02 2021 07:14:28 GMT+0000 (UTC)

Saved by @Sakshamkashyap7 #c++

// O(n) Linear search
void MinMaxValue(vector<int>arr)  {
    int mini = arr[0], maxi = arr[0];
    for(int i=1;i<arr.size();i++)   {
        if(arr[i]<mini) 
          mini = arr[i];
        if(arr[i]>maxi) 
          maxi = arr[i];
    }
    cout<<mini<<" "<<maxi;
}
content_copyCOPY