← Questions

Fewest global replacements to group equal values

0
AmazonCodingLast asked Aug 2026

A coding interview question asked in Amazon's online assessment, last asked Aug 2026. It tests greedy, arrays and intervals.

You are given an integer array arr of length n. In one operation you pick two different values x and y that both currently appear in arr, and you change every occurrence of x into y.

Sign in to unlock this question

The full prompt, the worked answer and your own canvas or code with the AI tutor. New accounts get 5 credits: each one unlocks a question for good.

Where it's asked

  • Amazon · Online assessment · Last asked Aug 2026Coding problems plus a repository bug-fix section with a built-in assistant or a design scenario, then a work-style survey · AI only inside the bug-fix section's built-in assistant

What it tests

greedy · arrays · intervals

Your code and the AI tutor open when you unlock this question.