You are viewing a single comment's thread. Return to all comments →
Solution without nested for loops (better time complexity)
from itertools import combinations, chain S = input().split() n = int(S[1]) combs = chain.from_iterable(combinations(sorted(S[0]), i) for i in range(1, n + 1)) for comb in combs: print(''.join(comb))
Seems like cookies are disabled on this browser, please enable them to open this website
itertools.combinations()
You are viewing a single comment's thread. Return to all comments →
Solution without nested for loops (better time complexity)