Given a string containing only letters, output the length of the longest run of consecutive alphabetical letters the word contains, where order does not matter. An example algorithm may sort the word, remove duplicates, and then output the length of the longest run.
Test Cases
watch -> 1
stars -> 3
antidisestablishmentarianism -> 3
backdoor -> 4
a -> 1
tutorials -> 4
For example, antidisestablishmentarianism
contains the letters abdehilmnstr
. The longest runs are lmn
and rst
, both of length 3.
Notes
You may take all lowercase, all uppercase, or mixed-case letters as input, but the case cannot encode information about the word (i.e. you cannot make the first n
characters capitalized where n
is the length of the longest run).
This is code-golf, so shortest answer in bytes wins.
rst
- uniquify, sort and get longest consecutive run. Can we take input as an array of characters? \$\endgroup\$