Celestial Skyline Layout
This challenge becomes much easier once you know exactly what to keep, change, or count. In Celestial Skyline Layout, you are trying to work toward the right number by following one clear idea.
Build recursive skyline layout structure 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 blueprint = 4, the answer is 1. Example with input: blueprint = 4 Another example is blueprint = {"base": {"base": 5, "steps": [1]}, "steps": [2, 3]}, which gives 8. Example with input: blueprint = {"base": {"base": 5, "steps": [1]}, "s
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 with input: blueprint = 4
Example with input: blueprint = {"base": {"base": 5, "steps": [1]}, "s
Example with input: blueprint = {"base": 4, "steps": [2]}
Algorithm Flow

Best Answers
import java.util.*;
class Solution {
private static final int MOD = 1000000007;
public int count_valid_skylines(Object blueprint) {
if (blueprint instanceof Number) {
return 1;
}
Map<String, Object> fork = (Map<String, Object>) blueprint;
long baseCount = count_valid_skylines(fork.get("base"));
List<?> steps = (List<?>) fork.get("steps");
int k = (steps != null) ? steps.size() : 0;
long pow2k = 1;
long b = 2;
while (k > 0) {
if (k % 2 == 1) pow2k = (pow2k * b) % MOD;
b = (b * b) % MOD;
k /= 2;
}
return (int) ((baseCount * pow2k) % MOD);
}
}Comments (0)
Join the Discussion
Share your thoughts, ask questions, or help others with this Challenge.
