Data Structure & Algorithm: Level-1 Problem #31. Dvorak Keyboard

Dvorak keyboard layout is different from the default QWERT keyboard we used everyday. It’s a faster and more ergonomic alternative to the QWERTY layout.

Dvorak proponents claim that it requires less finger motion and as a result reduces errors, increases typing speed, reduces repetitive strain injuries, or is simply more comfortable than QWERTY. Personally I used Dvorak for more than a year when working with my master tutor, Leo Jacob, on the ecommerce website ALLBOOKS back in 1995 as he highly recommended it. As a matter of fact, I found Dvorak is better than the QWERT layout.

Following image shows the Dvorak keyboard layout.

  • The top row of Dvorak keyboard consists letters – “P Y F G C R L”
  • The home row (center one) consists letters “A O E U I D H T N S”
  • The bottom row consists letters “Q J K X B M W V Z”.

Dvorak Layout

Given a list of words, find out which ones could be typed within one row of Dvorak keyboard.

Sample Input:

[‘data’, ‘input’, ‘hunt’, ‘sample’, ‘lettuce’, ‘dental’, ‘auto’, ‘human’]

Sample Output:

[‘data’, ‘hunt’, ‘auto’]


数据结构和算法:初级练习题 #31 – 德沃夏克键盘


德沃夏克键盘是以研制者德沃夏克命名的键盘。该键盘的布局特别考虑了操作速度和效率因素。它将5个元音键和最常用的辅音键安排在中间行,直接处于手指之下,这一排键可组成约3000个英文单词。而在QWERTY键盘同样位置上的那些键只能组成约100个英文单词。与QWERTY键盘对比,使用该键盘时手的工作负荷从左手转向右手,并且手指问的负荷分配也更为合理。

自己也曾经使用过德沃夏克键盘一年多时间,那是在1995年和自己的研究生导师Leo Jacob合作开发电商网站Allbooks时,在Leo大力推荐下尝试了德沃夏克键盘,的确比传统的QWERT键盘要好。

上图显示了德沃夏克键盘的布局:

  • 第一排(上部)键盘包括字母:”P Y F G C R L”
  • 第二排(中间)键盘包括字母:”A O E U I D H T N S”
  • 第三排(下部)键盘包括字母:”Q J K X B M W V Z”

给定一组单词,检查哪些单词可以在德沃夏克键盘的同一行打印出来。

输入样例:

[‘data’, ‘input’, ‘hunt’, ‘sample’, ‘lettuce’, ‘dental’, ‘auto’, ‘human’]

输出样例:

[‘data’, ‘hunt’, ‘auto’]

上面的输入样例中,单词 data,hunt,dental 和 auto 都可以用中间一行的键盘打印出来。


Python Solutions

Dvorak Keyboard