1165. Single-Row Keyboard
Description
**Input:** keyboard = "abcdefghijklmnopqrstuvwxyz", word = "cba"
**Output:** 4
**Explanation:** The index moves from 0 to 2 to write 'c' then to 1 to write 'b' then to 0 again to write 'a'.
Total time = 2 + 1 + 1 = 4. **Input:** keyboard = "pqrstuvwxyzabcdefghijklmno", word = "leetcode"
**Output:** 73ac
Last updated