Available question text
You may replace either number of any adjacent pair with their gcd; compute the minimum operations to make every element 1 (or return -1 if impossible). Key idea: if any element is 1 the answer is n - count(1); if gcd(all) > 1 it's impossible; otherwise find the shortest subarray whose gcd is 1 and the minimum operations = n + (subarray length) - 2.
Related questions
Continue with questions that share topics or the same question type.
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 2654. Minimum Number of Operations to Make All Array Elements Equal to 1
Reported date not specified · 0 source reports
Source snapshot: Nov 12, 2026
View source