国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

【LeetCode】500. Keyboard Row【E】【75】

2019-11-08 03:19:28
字體:
來源:轉載
供稿:網友

Given a List of Words, return the words that can be typed using letters of alphabet on only one row's of American keyboard like the image below.

American keyboard

Example 1:

Input: ["Hello", "Alaska", "Dad", "Peace"]Output: ["Alaska", "Dad"]

Note:

You may use one character in the keyboard more than once.You may assume the input string will only contain letters of alphabet.

Subscribe to see which companies asked this question.想法很簡單 就是用集和運算 然后看每個word是不是一行的子集最開始寫的時候 太傻了 被注釋掉了

class Solution(object):    def findWords(self, words):        #row1 = set(['Q','W','E','R','T','Y','U','I','O','P','q','w','e','r','t','y','u','i','o','p'])        #row2 = set(['A','S','D','F','G','H','J','K','L','a','s','d','f','g','h','j','k','l'])        #row3 = set(['Z','X','C','V','B','N','M','z','x','c','v','b','n','m'])        row1 = set('qwertyuiop')        row2 = set('asdfghjkl')        row3 = set('zxcvbnm')        res = []        for i in words:            si = set(i.lower())            #if len(si - row1) == 0 or len(si - row2) == 0 or len(si - row3) == 0:            if si.issubset(row1) or si.issubset(row2) or si.issubset(row3):                res += i,        return res        """        :type words: List[str]        :rtype: List[str]        """


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 平南县| 布拖县| 通辽市| 庄河市| 嫩江县| 南乐县| 莱阳市| 襄樊市| 策勒县| 清河县| 韶关市| 昌都县| 海晏县| 普兰县| 合水县| 双柏县| 南江县| 襄樊市| 阳泉市| 藁城市| 神池县| 广安市| 泰和县| 滦南县| 江安县| 永靖县| 新沂市| 长垣县| 舟曲县| 通海县| 竹北市| 鹰潭市| 邳州市| 富蕴县| 白玉县| 公安县| 宁河县| 商都县| 商都县| 山阴县| 峡江县|