Every Arrangement
letters is a string of distinct lowercase letters. Return a list with every string that can be formed by arranging all of its letters, each arrangement exactly once, in any order. The empty string has exactly one arrangement, the empty string itself, so "" gives [""].
For example, "abc" gives ["abc", "acb", "bac", "bca", "cab", "cba"] in some order.
Example 1
letters "abc"
returns ["abc","acb","bac","bca","cab","cba"]
Three distinct letters can be ordered in 3 * 2 * 1 = 6 ways.
Example 2
letters "xy"
returns ["xy","yx"]
Two letters give the two orders xy and yx.
Constraints
0 <= len(letters) <= 6- All letters are different lowercase letters
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.