def solution(s): keys = "22233344455566677778889999" # 每个字母在键上的位置(第几次按键) press = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 4, 1, 2, 3, 1, 2, 3, 4] total = 0 prev_key = '' for ch in s: idx = ord(ch) - ord('a') cur_key = keys[idx] total += press[idx] if cur_key == prev_key: tota...