Find largest product of longest subsequence between min and max
Jelly, 15 bytes
NMpMr/€LÐṀịµP€Ṁ
TryItOnline!
How?
NMpMr/€LÐṀịµP€Ṁ - Main link: list of integers, L
µ - links to the left as a monadic chain with argument L
N - negate elements of L
M - indexes of maximal elements (i.e. indexes of minimal elements of L)
M - indexes of maximal elements of L
p - Cartesian product of the min and max indexes
/€ - reduce each list (all of which are pairs) with the dyad:
r - range(a,b) (note if a>b this is [a,a-1,...,b])
ÐṀ - filter keeping those with maximal
L - length
ị - index into L (vectorises) (get the values)
P€ - product of a list for €ach
Ṁ - maximum
Perl 6, 108 bytes
{max ([*] $_ for .[.grep(+.max(+*)) with (for .min,.max,.max,.min {.first($^a,:k).. .first($^b,:k,:end)})])}
Jelly, 14 bytes
.ịạ/;L;P
ẆÇ€ṀṪ
Try it online!
How it works
ẆÇ€ṀṪ Main link. Argument: A (array)
Ẇ Window; generate all substrings of A.
Ç€ Map the helper link over the substrings.
Ṁ Take the maximum.
Ṫ Tail; select the last element.
.ịạ/;L;P Helper link. Argument: S (array / substring)
.ị At-index 0.5; select the last and first element of S.
ạ/ Reduce by absolute difference.
;L Append the length of S.
;P Append the product of S.