Challenge: Arithmetic Sequence
Explore how to detect the first outlier in an arithmetic sequence within an array using Java. Learn to handle edge cases like arrays with less than five elements and return appropriate indices. Gain practical experience identifying sequence errors through coding exercises and program testing.
Task
This task requires you to find the index of the first outlier in a given array. All numbers in an array are in an arithmetic sequence, except one number.
Write a program that uses an array and finds the index of the first outlier and stores it to the variable idx. The array is guaranteed to have at least elements and the first two elements will be in the required arithmetic sequence. The value of the idx should be ...