Quick Overview

Rearrange every occurrence in a digit string so each adjacent pair sums to at most nine. Return the lexicographically smallest valid arrangement, preserve leading zeroes, and return an empty string when no arrangement works.

Rearrange Digits Without Adjacent Sums Above Nine

Company: Amazon

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

Overview: Rearrange every occurrence in a digit string so each adjacent pair sums to at most nine. Return the lexicographically smallest valid arrangement, preserve leading zeroes, and return an empty string when no arrangement works.

Loading…