Company: Hackerrank_22oct
Difficulty: medium
Typing Distance Problem Description Imagine your computer has a keyboard layout like the one displayed below: 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 Assuming a keyboard typing robot. The robot's initial position is at the blue key with a star (which is 'Y'). Pressing any key on the keyboard generates the corresponding upper case letters and/or numbers. Given a string (with only uppercase letters and numbers), return the total distance traveled by the robot. The robot can move only left, right, top, and bottom. It can't move diagonally. Note: There will be no spaces included in the input provided. Function Description Complete the function getDistance in the editor below. Function Parameters: string word : the string to type using the robot arm Returns: int : the total distance covered by the robot arm Examples Example 1: Input: word = QZ Output: 7 Explanation: The robot starts at the star position ('Y'). From 'Y' to 'Q': 5 steps From 'Q' to 'Z': 2 steps