โ† Amazon questions

Duplicates within k indices

Filed under Amazon

Given an m x n 2D array and an integer k, determine if there are two identical elements at positions (r1, c1) and (r2, c2) such that their Manhattan distance |r1 - r2| + |c1 - c2| is at most k.

You've read your 3 free write-ups

Sign up free to keep reading. Your account opens the first 10 questions of every company.

Related Amazon questions

Collected from public candidate posts and coding forums. Updated Nov 2026.