Back to problems

Package Weight Rearrangement

Algorithm · Amazon · Medium

Valid Digit Rearrangement Medium · Array, Greedy, Counting · - · Hints You are given an array of integers digits where every element is a digit (i.e., an integer from 0 to 9 inclusive). Your task is to reorder the elements into a sequence such that for every two consecutive elements, their sum is at most 9. If such an ordering exists, return any valid arrangement. If it is impossible to satisfy the condition, return an empty array. Hints: Since the values are constrained to…

Checking your access…