HackerRank Python - Merge the Tools


Problem link- https://www.hackerrank.com/challenges/merge-the-tools/problem

  1. def merge_the_tools(string, k):
  2. # your code goes here
  3. temp = []
  4. len_temp = 0
  5. for item in string:
  6. len_temp += 1
  7. if item not in temp:
  8. temp.append(item)
  9. if len_temp == k:
  10. print (''.join(temp))
  11. temp = []
  12. len_temp = 0
  13. if __name__ == '__main__':
  14. string, k = input(), int(input())
  15. merge_the_tools(string, k)

download android app