Trains the technique from
LeetCode 60Permutation SequenceThis 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 calibration rig drives n nozzles, numbered 1 through n. Its test book holds every firing order of those nozzles exactly once, one order per line, each written as the nozzle numbers run together with nothing between them.
Every line of the book has the same number of digits, and the book is sorted by reading each line as a number and placing smaller numbers earlier. With n = 3 the book runs 123, then 132, then 213, then 231, then 312, and finally 321.
Given n and a line number k, with the opening line counted as line 1, return that line of the book as a string.
Example 1
Line 7 of the four-nozzle book reads 2134, which fires each of the nozzles 1, 2, 3 and 4 once.
Example 2
Line 13 of the five-nozzle book reads 14235, and every nozzle from 1 to 5 appears in it exactly once.
Example 3
One nozzle admits one firing order, so the book has the single line 1.
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 firing_order(n: int, k: int) -> str:public String firingOrder(int n, int k)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.