So according to me, the worst case time complexity will be 0(n^2)
the pseudo code is-------
find()
{ int B[n];
for ( int i=0; i<=n; i++ )
{
for ( int j=0; j<=n; j++)
{
int max= B[i] - B[j];
if( B[i] - B[j] <= max)
{ something}
else max= B[i] - B[j];
}
}
the two loops are running and number of comparisions made are (n-1)+ (n-2) + (n-3) + …...+2+1
worst case time complexity becomes 0(n^2)