We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
You can achieve higher speeds using an O(n) minimum and maximum calculating function!
void computeDifference()
{
int n=elements.size();
int min=100;
int max=1;
for(int i=0;i<n;++i)
{
if(elements[i]<min){min=elements[i];}
if(elements[i]>max){max=elements[i];}
}
maximumDifference=max-min;
Day 14: Scope
You are viewing a single comment's thread. Return to all comments →
You can achieve higher speeds using an O(n) minimum and maximum calculating function!
void computeDifference() {
}