LC: 1165. Single Row Keyboard
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: 73Last updated