# [LeetCode]#1974. Minimum Time to Type Word Using Special Typewriter

• Move the pointer one character counterclockwise or clockwise.
• Type the character the pointer is currently on.
`Input: word = "abc"Output: 5Explanation: The characters are printed as follows:- Type the character 'a' in 1 second since the pointer is initially on 'a'.- Move the pointer clockwise to 'b' in 1 second.- Type the character 'b' in 1 second.- Move the pointer clockwise to 'c' in 1 second.- Type the character 'c' in 1 second.`
1. if move <13, go clockwise. Else, go counterclockwise.
2. Add one second for type.
3. Summary all second
`class Solution:    def minTimeToType(self, word):        s=0        now='a'        for i in range(len(word)):            move=abs(ord(word[i])-ord(now))            if move > 13:                move= 26 -move            s+=(move+1)            now=word[i]        return s`

--

--

--

## More from Fatboy Slim

Interesting in any computer science.

Love podcasts or audiobooks? Learn on the go with our new app.

## Fatboy Slim

Interesting in any computer science.