Echoing Story Weaver
Every solstice in Alderaan Hollow, the Echo Weaver leads a layered recital. The tale begins with a base legend at its heart, wrapped in refrains from generations of apprentices. Each new voice adds their own introduction and epilogue, creating a beautifully symmetrical narrative. Your task in Echoing Story Weaver is to produce the exact multi-line script for this ceremony.
The "secret sauce" here is Recursive String Building. Each voice in the voices array (from nearest to furthest) contributes an intro line ("{name} echoes:") and a closing line ("{name} concludes."). These wrap around the core legend and all the inner echoes. The result is a strictly ordered script with newline separators. If no voices are present, the weaver simply speaks the base legend alone. This recursive pattern ensures that every family can follow the story correctly as it winds back to the present day.
This is a classic recursion problem that focuses on formatting and sequence. It’s the gold standard for understanding how recursive calls can "wrap" content to create complex, nested structures!
Examples
Example with input: base = "A river always remembers.", voices = ["Sel
Example with input: base = "The hearth keeps its promise.", voices = [
Example with input: base = "The hearth keeps its promise.", voices = [
Algorithm Flow

Best Answers
import java.util.*;
class Solution {
public String echoing_story_weaver(String base, String[] voices) {
if (voices.length == 0) return base;
StringBuilder sb = new StringBuilder();
for (String name : voices) {
sb.append(name).append(" echoes:
");
}
sb.append(base);
for (int i = voices.length - 1; i >= 0; i--) {
sb.append("
").append(voices[i]).append(" concludes.");
}
return sb.toString();
}
}Comments (0)
Join the Discussion
Share your thoughts, ask questions, or help others with this problem.
