Search
⌘K

Leetcode 2470. Number of Subarrays With LCM Equal to K

Count the number of contiguous subarrays whose least common multiple equals k, using the key observation that any subarray LCM must divide k so you can accumulate LCMs and stop when it no longer divides k. With nums.length and values ≤1000, an O(n^2) scan is feasible.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.