Trains the technique from
LeetCode 51N-QueensThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A survey team is siting n radio beacons on a ridge that has been divided into an n by n lattice of pads. Every pad is either empty or carries exactly one beacon.
Two beacons jam each other when they sit on the same lattice row, on the same lattice column, or on a common 45-degree line running either way through the lattice. A siting is clean when all n beacons are placed and no two of them jam each other.
Return every clean siting. Draw each one as a list of n strings of length n, one string per row from the top row down, using "B" for a pad carrying a beacon and "." for an empty pad. The sitings may come back in any order. When no clean siting exists, return an empty list.
Example 1
On a two by two lattice the two beacons always share a row, a column or a 45-degree line, so nothing is clean and the list comes back empty.
Example 2
Four clean sitings fit on a six by six lattice. In the first one the top beacon sits on pad 1 of its row, the next on pad 3, and so on down the ridge.
Example 3
Ten clean sitings fit on a five by five lattice, and they may be listed in any order.
The values you return may be in any order.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def beacon_layouts(n: int) -> list[list[str]]:public List<List<String>> beaconLayouts(int n)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.