Leetcode 500 Keyboard Row
2022-02-04 17:22 作者:您是打尖兒還是住店呢 | 我要投稿
Given an array of strings?words
, return?the words that can be typed using letters of the alphabet on only one row of American keyboard like the image below.
In the?American keyboard:
the first row consists of the characters?
"qwertyuiop"
,the second row consists of the characters?
"asdfghjkl"
, andthe third row consists of the characters?
"zxcvbnm"
.
如果字符都在一行中能夠打出來(lái),則可以輸出這個(gè)字符串,如果不行,就不輸出這個(gè)字符串;
類似官方的解答,將所有的字符所在的行數(shù)提前做好,判斷是否跟第一個(gè)都一樣,一樣就增加,不一樣就false,最后匯總,輸出,即可。
Runtime:?0 ms, faster than?100.00%?of?Java?online submissions for?Keyboard Row.
Memory Usage:?41.7 MB, less than?11.33%?of?Java?online submissions for?Keyboard Row.
標(biāo)簽: