Skip to content

Instantly share code, notes, and snippets.

@Abdujabbar
Created November 24, 2015 21:16
Show Gist options
  • Save Abdujabbar/15894d81c5636b2240fd to your computer and use it in GitHub Desktop.
Save Abdujabbar/15894d81c5636b2240fd to your computer and use it in GitHub Desktop.
Morgan and String
__author__ = 'abdujabbor'
def find_lex_min_string(s1, s2):
result = ''
i = 0
j = 0
while i < len(s1) and j < len(s2):
if s1[i:] < s2[j:]:
result += s1[i]
i += 1
elif s2[j:] < s1[i:]:
result += s2[j]
j += 1
if i < len(s1):
result += s1[i:]
if j < len(s2):
result += s2[j:]
return result
t = int(input())
for i in range(t):
print(find_lex_min_string(input(), input()))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment