Your Dashboard
Interview Coaching
Learn
System Design
ML System Design
Code
Behavioral
Salary Negotiation
Interview Guides
Search
⌘K
Get Premium
Leetcode 2197. Replace Non-Coprime Numbers in Array
Repeatedly scan the array and whenever two adjacent numbers have GCD>1 replace them with their LCM, continuing until no adjacent non-coprime pairs remain; return the final array. The challenge is to efficiently handle cascading merges (e.g., with a stack and gcd/lcm operations) for up to 1e5 elements (nums[i] ≤ 1e5, final values ≤ 1e8).
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
All Regions
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.