国产探花免费观看_亚洲丰满少妇自慰呻吟_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]        """


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 龙江县| 馆陶县| 康马县| 鹤庆县| 阿勒泰市| 商都县| 景谷| 洮南市| 化德县| 蓬溪县| 澜沧| 合川市| 铅山县| 吉安县| 株洲县| 抚松县| 吴堡县| 枝江市| 广德县| 宜宾市| 靖西县| 蓝山县| 抚顺县| 佛冈县| 大连市| 海林市| 诸城市| 礼泉县| 荣昌县| 连州市| 昌乐县| 马公市| 奇台县| 会宁县| 化德县| 丽水市| 靖州| 苏州市| 秦皇岛市| 金寨县| 石狮市|