05AB1E, 13 bytes
ŒʒlêAå}éΣág}н
Outputs an empty string as falsey (could have been 12 bytes if we would be allowed to output -1
as falsey with ŒéΣág}.ΔlêAå
).
Try it online or verify all test cases.
Explanation:
Œ # Get all substrings of the (implicit) input-string
ʒ # Filter this list by:
l # Convert the current substring to lowercase
ê # Uniquify and sort all characters in the string
A # Push "abcdefghijklmnopqrstuvwxyz"
å # Check if the lowercase alphabet is in the uniquify-sorted substring
}é # After the filter: sort any remaining substrings from shortest to longest
Σ # Then sort it again by:
á # Leave just all the letters of the substring
g # Pop and push the length
}н # After the sort-by: pop and leave just the first
# (or an empty string if the list is empty)
# (which is output implicitly as result)