3411. Maximum Subarray With Equal Products
You are given an array of positive integers
nums
.An array
arr
is called product equivalent ifprod(arr) == lcm(arr) * gcd(arr)
, where:
prod(arr)
is the product of all elements ofarr
.gcd(arr)
is the GCD of all elements ofarr
.lcm(arr)
is the LCM of all elements ofarr
.Return the length of the longest product equivalent subarray of
nums
.A subarray is a contiguous non-empty sequence of elements within an array.
The term
gcd(a, b)
denotes the greatest common divisor ofa
andb
.The term
lcm(a, b)
denotes the least common multiple ofa
andb
.
c++
1 | class Solution { |