-
-
Save Abdujabbar/15894d81c5636b2240fd to your computer and use it in GitHub Desktop.
Morgan and String
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__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