I want to be able to find the index of the end of a monotone decreasing subsequence which starts off at the first index of the list and only goes down in consecutive order. So for example, I may have a list that looks like this:
x = [89, 88, 88, 88, 88, 87, 88]
and I want to be able to return 5
because it is the index of the last element of the subsequence [89, 88, 88, 88, 88, 87]
, where each of the numbers in this subsequence are monotone decreasing and go down consecutively, starting at 89
, the first index of the list.
Say for example, I had a list that looked like this: x = [89, 87, 87, 86, 87]
. I would want to return 0
, because it is the only number that starts with the first index (89) and is monotonic decreasing consecutively (i.e., the next number in the list goes down from the first number by 2). Or if I had a list that looked like this: x = [89, 90, 89, 88]
, I would want to return 0
because it is the only part of the sequence that is monotone decreasing from the first index of the list.
Sorry for the difficulty in explaining. Thank you in advance for the help!