Ascending Manifest
In the fulfillment center's photo studio, shipments of collectible tins arrive labeled by number but rarely show up in order. The staging crew relies on a helper routine that reads the original manifest and produces a fresh list where labels climb steadily from the smallest value to the largest. They keep the raw manifest untouched for auditing, so the routine must build a separated copy that mirrors every label while presenting a calm, predictable sequence ready for layout review.
Sometimes an event run introduces duplicate labels for matching crates, and the crew needs those repetitions to remain visible in the returned list. Other times emergency returns add negative identifiers, while limited editions push values well beyond the usual range. Regardless of size or sign, each entry must appear in its rightful place in the rising order without losing a single label. When the shipment is already tidy, the routine should simply echo what it received so the staff can move on.
The logistics lead runs a validation pass before handing the manifest to photographers, comparing the routine's output with a trusted reference list. Any difference—missing labels, altered order, unexpected padding—forces a time-consuming recount and delays the shoot schedule. Produce a result that exactly matches the expected ascending manifest, including handling of empty shipments by returning an empty list, so the approval check completes instantly and the merchandising team can set the stage without surprises.
Example 1:
Input: nums = [7,2,5,2]
Output: [2,2,5,7]
Explanation: The returned manifest lists the labels from smallest to largest while keeping both copies of 2.
Example 2:
Input: nums = []
Output: []
Explanation: An empty shipment produces an empty manifest.
Example 3:
Input: nums = [4,-1,4,3]
Output: [-1,3,4,4]
Explanation: Negative and positive labels appear in ascending order, with repeated values preserved.
Related Problems
No related problems found
Comments (0)
Join the Discussion
Share your thoughts, ask questions, or help others with this problem.
