#K59397. Unique Combinations of Characters
Unique Combinations of Characters
Unique Combinations of Characters
Given an integer \(n\) and a string \(s\) of length \(n\), your task is to generate all unique combinations (subsequences) of the characters in \(s\) while maintaining the order of characters. Combinations can have lengths ranging from 1 to \(n\).
The result should be a sorted list (in lexicographical order) of all unique combinations. For example, for the input string "aab" with \(n=3\), the unique combinations are: \(a, aa, aab, ab, b\).
inputFormat
The first line contains an integer (n) representing the length of the string. The second line contains the string (s).
outputFormat
Output all unique combinations, each on a separate line, in sorted (lexicographical) order.## sample
3
aab
a
aa
aab
ab
b
</p>