HackerRank Python - itertools.combinations_with_replacement()

You are given a string S.
Your task is to print all possible size K replacement combinations of the string in lexicographic sorted order.

  1. # Enter your code here. Read input from STDIN. Print output to STDOUT
  2. from itertools import combinations_with_replacement
  3. s,k=input().split()
  4. for i in combinations_with_replacement(sorted(s),int(k)):
  5. print ("".join(i))


Codesadda.com is your home of programming solutions, tutorials, video tutorials and much more. Sign Up for our weekly newsletter to get update about new content.

Like us on Facebook | Connect with us on LinkedIn | Subscribe our Channel on Youtube