Moderate# Run Time Analysis of Two Methods with Array Parameter

APCSA-BXVVPY

Consider the following two methods.

```
// return the last number in the array that is greater than 10
// return -1 if no numbers > 10 are found
public static int methodA(int[] nums)
{
int index = -1;
for (int i=0; i<nums.length; i++)
{
if (nums[i] > 10)
index = i;
}
if (index >=0)
return nums[index];
return -1;
}
// return the last number in the array that is greater than 10
// return -1 if no numbers > 10 are found
public static int methodB(int[] nums)
{
int index = -1;
for (int i=nums.length-1; i>=0; i--)
{
if (nums[i] > 10)
return nums[i];
}
return -1;
}
```

When would **methodA** execute faster than **methodB**?