Replace Non-Coprime Numbers in Array

Given an array of positive integers nums, repeatedly perform the following operation until no more operations are possible:

  • Find adjacent elements nums[i] and nums[i + 1]. If their greatest c...

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Standard Input
Execution Result: