Company: hackerrank_19oct
Difficulty: medium
Typing Distance Problem Description A typing robot works on a keyboard whose keys are laid out as a grid of four rows: 1 2 3 4 5 6 7 8 9 0 Q W E R T Y U I O P A S D F G H J K L Z X C V B N M The rows are left-aligned. A key's row is the index of the line it sits on ( 0 for the digits, 3 for Z X C V B N M ), and a key's column is its position inside its own row, counting from 0 . So 1 , Q , A and Z all sit in column 0 , while 0 and P sit in column 9 . The robot's arm starts on the highlighted key Y , at row 1 , column 5 . To type a character the arm moves onto that character's key and presses it. The arm moves only left, right, up and down — never diagonally — so moving from one key to another costs the Manhattan distance between them: distance = |row_from - row_to| + |col_from - col_to| Pressing a key costs nothing, and typing a character that is already under the arm costs nothing. Given a string word made of uppercase letters and digits, return the total distance the arm