BudiBadu Logo

Conveyor Batch Sequence

Sorting Easy 3 views
Like15

Technical Goal

Implement a function that takes an array of integers and returns a new array with the elements sorted in ascending order. The original array must remain unchanged.

Constraints

  • nums: An array of integers (can include negative numbers and duplicates).
  • Return a new sorted array; do not modify the original.
  • Empty input should return an empty array.

Algorithm Flow

Recommendation Algorithm Flow for Conveyor Batch Sequence - Budibadu
Recommendation Algorithm Flow for Conveyor Batch Sequence - Budibadu

Best Answers

java
import java.util.*;

class Solution {
    public int[] conveyor_batch_sequence(int[] nums) {
        int[] result = nums.clone();
        Arrays.sort(result);
        return result;
    }
}