Conveyor Batch Sequence
In the packaging warehouse, each conveyor batch is recorded as a weight label, but the monitoring screen lists them in the order they left the scale rather than the calm progression the palletizing robot expects. The shift engineer wants a routine that reads the live feed and returns a fresh array where the labels climb from lightest to heaviest. The original feed stays archived for compliance, so the routine must produce a separate ordered copy that operators can hand to the robot console.
Rush orders often send identical weights back-to-back, while recall drills insert negative markers to block certain slots. The routine needs to keep every weight, placing them into the rising sequence without collapsing duplicates or skipping unusual values. When the feed already happens to be sorted, it should return the same list untouched, giving the engineer confidence that no additional staging is required before the pallets begin stacking.
Before sign-off, the quality supervisor compares the routine's output with a reference manifest that represents the desired stack order. Any mismatch - missing entry, wrong placement, or unexpected filler - halts the line until the discrepancy is cleared. Deliver an ordered list that mirrors the reference, including the quiet case where the feed is empty and the response must also be empty, so the crew can keep focus on throughput targets instead of troubleshooting the reporting panel.
Example 1:
Input: nums = [12,7,7,9]
Output: [7,7,9,12]
Explanation: Duplicate weights remain while the list climbs from lightest to heaviest.
Example 2:
Input: nums = [-2,5,-2,3]
Output: [-2,-2,3,5]
Explanation: Negative markers and positive weights are preserved in ascending order.
Example 3:
Input: nums = []
Output: []
Explanation: An empty feed results in an empty ordered list.
Related Problems
No related problems found
Comments (0)
Join the Discussion
Share your thoughts, ask questions, or help others with this problem.
