Lantern Pattern Paths
At the Festival of Threads, architects illuminate a riverside maze with lantern arcs that shimmer above the tide. The design always begins with a single walkway, described by a short phrase that tells visitors when to pause and look up. Curators then announce how many mirrored corridors will wrap around that walkway. Each corridor has a signature name—such as "Azure Bridge" or "Golden Spine"—and ushers recite a predictable rhythm when guiding guests through the added layer.
The rhythm never changes. To surround an inner layout with a corridor named marker, ushers first say "Enter {marker}" while stepping into the new lights. They let guests experience the inner layout completely, then whisper "Mirror {marker}" to signal the balanced return, replay the inner layout again, and finally announce "Exit {marker}" to close the loop. When no corridors remain, the only phrase spoken is the base walkway description. Each layer therefore wraps the inner list of phrases with three new lines and a second pass through the inner path, creating a woven experience that still respects the original center.
You must list every phrase in the order the ushers speak them. The input provides base, the innermost walkway phrase, and markers, an array of corridor names ordered from the closest layer outward. Return an array of strings describing the full script. If markers is empty, return an array containing only base. Otherwise process the markers recursively: the first element wraps the base, the second wraps that result, and so on.
Examples
Example with input: base = "Pause by the willow.", markers = []
Example with input: base = "Listen for distant bells.", markers = ["Go
Example with input: base = "Pause by the willow.", markers = ["Azure B
Algorithm Flow

Best Answers
class Solution {
public int lantern_pattern_paths(int m, int n) {
return (int) nCr(m + n - 2, m - 1);
}
private long nCr(int n, int r) {
if (r > n) return 0;
if (r == 0 || r == n) return 1;
if (r > n / 2) r = n - r;
long res = 1;
for (int i = 1; i <= r; i++) {
res = res * (n - i + 1) / i;
}
return res;
}
}Comments (0)
Join the Discussion
Share your thoughts, ask questions, or help others with this problem.
