BudiBadu Logo

Glacier Signal Fires

Array Easy 2 views
Like22

On the high Glacier Ridges, signal watchers light fires to communicate between camps. Each camp has a numeric frequency ID, and to prevent interference, the scouts need an orderly log of all active fires. Your mission in Glacier Signal Fires is to take a jumbled list of frequency IDs and return a fresh version where the numbers climb from the smallest frequency to the largest.

The "secret sauce" here is Non-Destructive Sorting. You must return a brand-new list so the original scout logs remain untouched for later review. Your routine must handle IDs for overlapping regions (duplicates), specialized signals (negative values), and large frequency ranges with ease. If the logs are already in order, just return a clean, sorted copy of the data. This simple but vital routine turns a messy assortment of scout reports into a clear, professional communication plan that keeps the Ridge teams in sync through every storm!

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
ridges = 4
Output
121
Explanation

Four responding ridges keep the rule, ending with one guiding fire plus triple the blaze from ridge three.

Example 2
Input
ridges = 2
Output
13
Explanation

The second ridge adds a beacon and repeats the earlier lights three times.

Example 3
Input
ridges = 0
Output
1
Explanation

Only the opening signal burns.

Algorithm Flow

Recommendation Algorithm Flow for Glacier Signal Fires - Budibadu
Recommendation Algorithm Flow for Glacier Signal Fires - Budibadu

Best Answers

java
class Solution {
    public int glacier_signal_fires(Object input) {
        int ridges = (int) input;
        return (int)((Math.pow(3, ridges + 1) - 1) / 2);
    }
}