Code Logo

Festival Stall Order

Published atDate not available
Easy 0 views
Like0

Imagine a festival game where you are trying to keep everything in the best order. In Festival Stall Order, you are trying to work toward the right list by following one clear idea.

You are given numbers, words, or labels that are not in the right order yet. Your task is to rearrange them so they line up the way the problem wants. That usually means comparing values carefully and making sure nothing gets lost or changed by mistake. After you finish, the result should feel neat and easy to read.

For example, if the input is nums = [13], the answer is [13]. A single stall stays unchanged because the identifiers were already ordered. Another example is nums = [21,8,21,4], which gives [4,8,21,21]. Shared stalls keep both entries while the list climbs from smallest to largest.

This is a friendly practice problem, but it still rewards careful reading. Keep your eye on the order from start to finish, and make sure the final list is exactly how the question wants it.

Example Input & Output

Example 1
Input
nums = [13]
Output
[13]
Explanation

A single stall stays unchanged because the identifiers were already ordered.

Example 2
Input
nums = [21,8,21,4]
Output
[4,8,21,21]
Explanation

Shared stalls keep both entries while the list climbs from smallest to largest.

Example 3
Input
nums = [5,-1,5,2]
Output
[-1,2,5,5]
Explanation

Negative placeholders and duplicates remain visible in ascending order.

Algorithm Flow

Recommendation Algorithm Flow for Festival Stall Order
Recommendation Algorithm Flow for Festival Stall Order

Best Answers

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