1. Create a function that accepts an array, containing non-zero integers with alternating signs.
a. AltSigns(array as array of integers) returning an integer (index).
2. However, the array may contain an extra element somewhere in the array, such that it will break the pattern (alternating signs).
a. Example: [-1, 1, -2, 8, 2, -3, 3]
b. In this example, you see that when the array has 8 and 2 as non-alternating signs. So, if you remove either 2 or 8, then the array will be in the right format.
3. The function will use a binary search to identify the index of where the non-alternating value occurs. (You can return either index of the non-alternating pair)
a. In the previous example, the function should return either an index of 3 or 4 because when you remove either values, 8 or 2, you will get an array with alternating signs.
b. You're right if you return either 3 or 4.
c. Make sure that you take care of the reference values (e.g. first couple), e.g., [2. 2. -1. 2. 3. 4] should result in either an index of 0 or 1.
d. You should try to put the numbers at the endpoints (beginning or at the end).
For the toolbar, press ALT+610