#3411
Maximum Subarray With Equal Products
easy · 46.6% accepted · 101 likes · top 31%
array · math · sliding window · enumeration · number theory
Description
You are given an array of positive integers nums.
An array arr is called product equivalent if prod(arr) == lcm(arr) * gcd(arr), where:
- prod(arr) is the product of all elements of arr.
- gcd(arr) is the GCD of all elements of arr.
- lcm(arr) is the LCM of all elements of arr.
Return the length of the longest product equivalent subarray of nums.
Solution