Code Logo

Emberstone Step Glow

Published atDate not available
Easy 0 views
Like0

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

Illuminate emberstone step markers recursively 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 terraces = 2, the answer is 21. The second terrace adds one ember and mirrors the earlier route four times. Another example is terraces = 5, which gives 1365. Five terraces maintain the rule, revealing a glowing path of 1365 embers.

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
terraces = 2
Output
21
Explanation

The second terrace adds one ember and mirrors the earlier route four times.

Example 2
Input
terraces = 5
Output
1365
Explanation

Five terraces maintain the rule, revealing a glowing path of 1365 embers.

Example 3
Input
terraces = 0
Output
1
Explanation

Only the first emberstone glows.

Algorithm Flow

Recommendation Algorithm Flow for Emberstone Step Glow
Recommendation Algorithm Flow for Emberstone Step Glow

Best Answers

java
class Solution {
    public int emberstone_step_glow(int[] nums, int k, int s) {
        int total = 0;
        for (int i = 0; i <= k; i++) {
            int idx = i * s;
            if (idx < nums.length) {
                total += nums[idx];
            }
        }
        return total;
    }
}