Time to Type a String
Problem Overview
- Compute the total time to type a text on a single-row keyboard based on finger movement between indices.
- Input: keyboard (26 unique lowercase letters) and text; start at index 0; movement time is abs(j - i).
- Output: an integer total time; constraints: text length 1–100,000 and letters are a–z.
- Simulates typing on a custom layout; a Google interviews problem and a common coding interview interview question.
Example
Unlock to view complete problem details
and practice with sample input/output
Was this article helpful?
View Test Cases & Run Code requires membership
Input Variables
Execution Result:
