Mirror Lantern Glow
This problem feels like a little puzzle you can solve one step at a time. In Mirror Lantern Glow, you are trying to work toward the right number by following one clear idea.
Calculate mirror lantern expansion 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 layers = 2, the answer is 7. The new layer adds one lantern, and the previous layers contribute twice their earlier total, giving seven perceived lanterns. Another example is layers = 0, which gives 1. Only the central lantern is visible, so the total count is one.
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
The new layer adds one lantern, and the previous layers contribute twice their earlier total, giving seven perceived lanterns.
Only the central lantern is visible, so the total count is one.
Five layers mean a fresh lantern plus mirrored echoes of all earlier layers, leading to thirty-one points of light.
Algorithm Flow

Best Answers
class Solution {
public int mirror_lantern_glow(Object input) {
int layers = (int) input;
return (int) Math.pow(2, layers + 1) - 1;
}
}Comments (0)
Join the Discussion
Share your thoughts, ask questions, or help others with this Challenge.
