Word gap fingerprint

Write codeEasy11 min

Your task

A typo detector fingerprints lowercase words by the gaps between adjacent letters. Given a word of lowercase letters, return the list of differences between each letter's alphabet position and the previous letter's, for adjacent letters s[i-1] and s[i], the gap is position(s[i]) minus position(s[i-1]) and may be negative. A word with fewer than two letters returns an empty list. For example, 'ace' returns [2, 2] and 'ba' returns [-1].

Examples

letter_gaps(word: str) -> list[int]
Example 1
Inputletter_gaps("ace")
Output[2, 2]