Ember Glyph Mosaic
This problem feels like a little puzzle you can solve one step at a time. In Ember Glyph Mosaic, you are trying to work toward the right list by following one clear idea.
Build glyph mosaic with expanding rings 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 base = ["*"], bands = ["North"], the answer is ["North^", "*", "vNorth", "*"]. Example with input: base = ["*"], bands = ["North"] Another example is base = ["*"], bands = [], which gives ["*"]. Example with input: base = ["*"], bands = []
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: base = ["*"], bands = ["North"]
Example with input: base = ["*"], bands = []
Example with input: base = [".o.", "ooo"], bands = ["Amber", "Quartz"]
Algorithm Flow

Best Answers
import java.util.*;
class Solution {
public String[] ember_glyph_mosaic(String[] base, String[] bands) {
return build(Arrays.asList(base), bands, 0).toArray(new String[0]);
}
private List<String> build(List<String> current, String[] bands, int idx) {
if (idx >= bands.length) return new ArrayList<>(current);
String marker = bands[idx];
List<String> inner = build(current, bands, idx + 1);
List<String> result = new ArrayList<>();
result.add(marker + "^");
result.addAll(inner);
result.add("v" + marker);
result.addAll(inner);
return result;
}
}Comments (0)
Join the Discussion
Share your thoughts, ask questions, or help others with this Challenge.
