Code RoomWord gap fingerprint
EasyPrep Room Coding #597

Word gap fingerprint

CodingAlgorithms & data structuresEntry–Mid~11 min

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].

Implement
letter_gaps(word: str) → list[int]
Examples
in["ace"]out[2,2]
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

0:00 of about 11 min
InputExpectedGot
["ace"][2,2]not run yetsample