21 lines
351 B
Python
21 lines
351 B
Python
from collections import Counter
|
|
|
|
def solution(X, Y):
|
|
cntX = Counter(X)
|
|
cntY = Counter(Y)
|
|
|
|
ans = ""
|
|
|
|
for k in "9876543210" :
|
|
ans += (k * min(cntX[k], cntY[k]))
|
|
|
|
if len(ans) == 0 :
|
|
ans = "-1"
|
|
elif ans[0] == "0" :
|
|
ans = "0"
|
|
|
|
return ans
|
|
|
|
# X = "5525"
|
|
# Y = "1255"
|
|
# print(solution(X, Y)) |