Time to Type a String
Asked at Google · Coding & Leetcode-style Questions · Difficulty: Easy
Imagine you have a special keyboard with all keys in a single row. The layout of characters on a keyboard is denoted by a string `keyboard` of length 26. Initially your finger is at index 0. To type a character, you have to move your finger to the index of the desired character. The time taken to move your finger from index i to index j is `abs(j - i)`.
Loading the problem…
More Google interview questions
- LLM conceptual questions
- Implement a Nested Tic-Tac-Toe Game Engine
- ML Fundamentals Deep Dive (AI/ML & MLE Roles)
- ML System Design: Recsys, Chatbot, Image Classifier
- ML Coding: Implement a Simple Attention / Layer Forward Pass
- Longest-Match Greedy Tokenization with Dictionary ID Replacement