The TransCompilator

Solved LeetCode program · 46 of 1,000

#0046 · Permutations

Medium Array chunk-01.md

Original English source

Keep a shared nums holding 1, 2, and 3. Keep a shared used as an empty list of whole numbers. Keep a shared parts as an empty list of text. Keep a shared answers as an empty list of text.
To permute from depth (a whole number). If depth is 3, The built is join parts with "", Place built into answers, then return.
For every position from 0 to 2.
If used contains position, skip to the next one. Place position into used. The piece is format whole number item position of nums as text. Place piece into parts. Permute from depth plus 1. Remove the last item from used. Remove the last item from parts.

Permute from 0. For each answer in answers, display answer.

Open in Playground Browse all 1,000 problems

Expected stdout

123
132
213
231
312
321