Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def getSmallestString(word,substr):
- for i in range(len(word)):
- if word[i] == "?":
- start = i
- end = start
- while word[end] == "?":
- end += 1
- # print(word[end])
- if word[end] in substr:
- if substr.index(word[end]) == abs(start-end):
- # word[start:end] = substr[:substr.index(word[end])]
- word = word.replace(word[start:end],substr[:substr.index(word[end])],1)
- print(word)
- else:
- if len(substr[substr.index(word[end]):]) >= abs(start-end):
- word = word.replace(word[start:end],substr[substr.index(word[end]):substr.index(word[end])+abs(start-end)],1)
- else:
- return -1
- return word
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement