Company: Hsbc

Difficulty: easy

Problem Statement

Keypad Strokes The keypad shown below works as follows. To type a , it requires a single stroke on the 2 button; to type b , it requires two strokes on the 2 button; to type c , it requires three strokes on the 2 button; to type d , it requires a single stroke on the 3 button. It works the same way for the other alphabets. Button Letters 2 a b c 3 d e f 4 g h i 5 j k l 6 m n o 7 p q r s 8 t u v 9 w x y z For each stroke, one second of time is consumed. If two characters are typed using the same button consecutively, one second of additional time will be required. You are given a string str ; print the time taken to type str using the given keypad. Note: the string str can be empty. Input Format The input is given in the following format: The first line of the input contains a single integer N denoting the length of str . The second line contains a string str . When N is 0 , the second line is present but empty. Input will be read from the STDIN by the candidate. Output Format Print the

More Hsbc OA questionsInterview experiences