#3411

Maximum Subarray With Equal Products

pupil · 485 · lc easy +27 · 46.6% accepted · 101 likes · top 31%

Description

You are given an array of positive integers nums.

An array arr is product-equivalent if prod(arr) == lcm(arr) * gcd(arr), where:

- prod(arr) is the product of all elements.

- gcd(arr) is the GCD of all elements.

- lcm(arr) is the LCM of all elements.

Return the length of the longest product-equivalent subarray of nums.

Code

1
2
3