
Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
The constraints on nums.length are small. It is possible to check every subarray.
To calculate LCM, you can use a built-in function or the formula lcm(a, b) = a * b / gcd(a, b).
As you calculate the LCM of more numbers, it can only become greater. Once it becomes greater than k, you know that any larger subarrays containing all the current elements will not work.