Quick Overview

Given an array of positive integers, find the fewest operations that make every element 1, where each operation replaces one of two neighboring values with their greatest common divisor, or return -1 if it cannot be done. Tests GCD properties, lower-bound reasoning and careful case analysis on small arrays.

Fewest Adjacent-GCD Operations to Turn Every Array Element into 1

Company: Otter.Ai

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

Overview: Given an array of positive integers, find the fewest operations that make every element 1, where each operation replaces one of two neighboring values with their greatest common divisor, or return -1 if it cannot be done. Tests GCD properties, lower-bound reasoning and careful case analysis on small arrays.

Read the full Otter.Ai Software Engineer interview experience this question came from

Loading…