Available question text
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).
Related questions
Continue with questions that share topics or the same question type.
- Binary Searchable Numbers in an Unsorted Array
Coding · Array · Binary Search · Monotonic Stack
- Bitwise OR of Even Numbers in an Array
Coding
- Count Numbers with Non-Decreasing Digits
Coding
- Divide Array in Sets of K Consecutive Numbers
Coding
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
No company association
Leetcode 2197. Replace Non-Coprime Numbers in Array
Reported date not specified · 0 source reports
Source snapshot: Nov 12, 2026
View source