โ† Amazon questions

Arrange string so characters are K distance apart

Filed under Amazon

Given a string and an integer k, rearrange the string such that the same characters are at least k distance apart. Return any valid arrangement or -1 if impossible.

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.