Backtracking with choices
List every two-letter string with no duplicates, exploring letters in the order given.
Examples
Example 1
Input
A, B, C
Expected output
AB, AC, BA, BC, CA, CB
Example 2
Input
A
Expected output
No sequences
Hints and solution
Hint 1
List all strings with the same first letter before moving to the next choice.
Reveal worked answer
With A, B, and C, the A branch emits AB and AC. The B branch emits BA and BC. The C branch emits CA and CB. Each time a branch finishes, restore the prefix before trying the next letter.