← Back to List

16588번: Substring Permutation ↗

Solutions

Python 3
265 B | 265 chars
a = sorted(list(input()))
b = sorted(list(input()))

i = j = 0

while i < len(a) and j < len(b):
    if a[i] == b[j]:
        i += 1
        j += 1
    elif a[i] < b[j]:
        i += 1
    else:
        i += 1

if j == len(b):
    print("YES")
else:
    print("NO")