Code Logo

Windborne Lantern Parade

Published at05 Jan 2026
Multi Dimensional Easy 16 views
Like29

This problem feels like a little puzzle you can solve one step at a time. In Windborne Lantern Parade, you are trying to work toward the right number by following one clear idea.

Calculate windborne lantern parade pattern A good way to think about it is to first understand what goes in, then what rule you must follow, and finally what shape the answer should have.

For example, if the input is tiers = 5, the answer is 63. Five tiers follow the ritual, filling the sky with sixty-three lanterns. Another example is tiers = 3, which gives 15. The third tier adds a lantern and repeats the earlier tiers twice.

This is a friendly practice problem, but it still rewards careful reading. The key is understanding the rule clearly and then applying it carefully.

One helpful habit is to say the rule out loud in your own words before you start solving. If you can explain what counts, what changes, and what the final answer should look like, you are already much closer to the right solution.

Example Input & Output

Example 1
Input
tiers = 5
Output
63
Explanation

Five tiers follow the ritual, filling the sky with sixty-three lanterns.

Example 2
Input
tiers = 3
Output
15
Explanation

The third tier adds a lantern and repeats the earlier tiers twice.

Example 3
Input
tiers = 0
Output
1
Explanation

Only the first lantern glider is airborne.

Algorithm Flow

Recommendation Algorithm Flow for Windborne Lantern Parade

Solution Approach

This problem follows the same style of repeating growth as other pattern challenges. Each tier adds one lantern and repeats the earlier tiers twice, so the total at any tier depends directly on the total from the tier before it.

The rule is: the new total equals 1 + 2 * (previous total). We can simulate this easily with a loop that runs once for each tier, keeping a running total.

We begin with a single lantern, then update the total for every tier:

function windborne_lantern_parade(tiers) {
    let result = 1;
    for (let i = 0; i < tiers; i++) {
        result = 1 + 2 * result;
    }
    return result;
}

The important line is result = 1 + 2 * result. Each pass takes the current total, doubles it (the repeated earlier tiers), and adds one for the new lantern.

Let us trace tiers = 3. We start with result = 1. After the first tier, result = 1 + 2 * 1 = 3. After the second, result = 1 + 2 * 3 = 7. After the third, result = 1 + 2 * 7 = 15. That matches the expected answer of 15.

This is efficient because it needs exactly tiers steps. The time complexity is O(tiers) and the space complexity is O(1), as we only track a single running value.

Best Answers

java
class Solution {
    public int windborne_lantern_parade(int tiers) {
        int result = 1;
        for (int i = 0; i < tiers; i++) {
            result = 1 + 2 * result;
        }
        return result;
    }
}