BudiBadu Logo

Harbor Cargo Lineup

Stack Easy 0 views
Like24

At the harbor yard, the console logs container tags exactly as they arrive. This often results in a jumble reflecting the busy day. Your mission in Harbor Cargo Lineup is to take these raw tags and produce a freshly sorted list where the numbers climb from the smallest tag to the largest. This lets crews coordinate with stacking managers much more efficiently!

The "secret sauce" here is Ascending Sorting. In a busy shift, you'll encounter duplicate tags and negative placeholders for reserved aisles. Your routine must preserve every single tag while rearranging them in a clean, non-decreasing order. The original console feed must remain untouched, so always return a brand-new copy. This approach ensures that everything is ready for customs and that no shipments are misplaced. It’s a fundamental building block for any software managing inventory or logistics logs!

If sorting is part of the strategy, do it intentionally as a preprocessing step to simplify downstream logic such as merging, ordering, or comparison. After sorting, keep output semantics precise: preserve expected structure, avoid dropping valid entries, and ensure tied cases still follow deterministic order rules.

Examples

Example 1
Input
nums = [42,17,17,5]
Output
[5,17,17,42]
Explanation

Duplicate container tags remain while the list rises from smallest to largest.

Example 2
Input
nums = [12,-4,7,0]
Output
[-4,0,7,12]
Explanation

Negative placeholders and standard tags appear together in ascending order.

Example 3
Input
nums = []
Output
[]
Explanation

An empty shift returns an empty lineup for the crew.

Algorithm Flow

Recommendation Algorithm Flow for Harbor Cargo Lineup - Budibadu
Recommendation Algorithm Flow for Harbor Cargo Lineup - Budibadu

Best Answers

java
import java.util.*;
class Solution {
    public Object harbor_cargo_lineup(Object input) {
        int[] nums = (int[]) input;
        int[] res = nums.clone();
        Arrays.sort(res);
        return res;
    }
}