{"id":6,"date":"2017-03-12T12:57:39","date_gmt":"2017-03-12T19:57:39","guid":{"rendered":"http:\/\/zxi.mytechroad.com\/blog\/?p=6"},"modified":"2018-04-19T08:44:09","modified_gmt":"2018-04-19T15:44:09","slug":"leetcode-keyboard-row","status":"publish","type":"post","link":"https:\/\/zxi.mytechroad.com\/blog\/leetcode\/leetcode-keyboard-row\/","title":{"rendered":"\u82b1\u82b1\u9171 Leetcode 500. Keyboard Row"},"content":{"rendered":"<pre class=\"lang:c++ decode:true  \">class Solution {\r\npublic:\r\n    bool check(const string&amp; word, const string&amp; row) {\r\n        for(char c : word) {\r\n            if(row.find(tolower(c)) == string::npos)\r\n                return false;\r\n        }\r\n        return true;\r\n    }\r\n    \r\n    vector&lt;string&gt; findWords(vector&lt;string&gt;&amp; words) {\r\n        const vector&lt;string&gt; rows = { \r\n            \"qwertyuiop\", \r\n            \"asdfghjkl\", \r\n            \"zxcvbnm\"\r\n        };\r\n        \r\n        vector&lt;string&gt; ans;\r\n        \r\n        for(const auto&amp; word : words) {\r\n            for(const auto&amp; row : rows) {\r\n                if(check(word, row)) {\r\n                    ans.push_back(word);\r\n                    break;\r\n                }\r\n            }\r\n        }\r\n        \r\n        return ans;\r\n    }\r\n};<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>class Solution { public: bool check(const string&amp; word, const string&amp; row) { for(char c : word) { if(row.find(tolower(c)) == string::npos) return false; } return true;&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[6,5,4],"class_list":["post-6","post","type-post","status-publish","format-standard","hentry","category-leetcode","tag-leetcode","tag-oj","tag-string","entry","simple"],"_links":{"self":[{"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/posts\/6","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/comments?post=6"}],"version-history":[{"count":3,"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/posts\/6\/revisions"}],"predecessor-version":[{"id":2737,"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/posts\/6\/revisions\/2737"}],"wp:attachment":[{"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/media?parent=6"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/categories?post=6"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/tags?post=6"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}