Amazon Interview Question

how to find the min and max in an array

Interview Answer

Anonymous

Mar 12, 2012

Find max: O(n) max = arr[0]; i: 1->n-1 if(max n-1 if(min > arr[i]) min = arr[i];