3 ms·
From a more abstract point of view we just build a loop through all permutations of numbers 1,2,..,n. Probably the most efficient algorithm for this task is thi
by dandanua 6y ago
From a more abstract point of view we just build a loop through all permutations of numbers 1,2,..,n. Probably the most efficient algorithm for this task is this one https://en.m.wikipedia.org/wiki/Steinhaus%E2%80%93Johnson%E2%80%93Trotter_algorithm https://en.m.wikipedia.org/wiki/Steinhaus%E2%80%93Johnson%E2...