Solutions for Changing Sequence
View the challenge

This challenge requires you to determine at what index in an array the sequence changes from increasing to decreasing or vice versa. For example, if the array were [1, 2, 4, 6, 4, 3, 1] then your program should return 3 because at index 3 the sequence begins to change from increasing to decreasing. If there is no change in sequence, then your program should return -1. To solve this challenge, we'll loop through the array checking if each change between numbers matches the prior change. We do this until we reach a point in the array where the sequence changes.

You need to be a member to see the rest of this solution and code.