Leetcode Keyboard Row500 Java

Source: Internet
Author: User

1  Public classSolution {2      Publicstring[] Findwords (string[] words) {3List<string> onerowwords =NewArraylist<string>();4String[] Keyboard = {"Qwertyuiop", "ASDFGHJKL", "ZXCVBNM"};5          for(String word:words) {6String Realword =Word;7Word = Word.tolowercase ();//each letter becomes lowercase8             Char[] Strbit =Word.tochararray ();9             intCount = 0;Ten              for(Charch:strbit) { One                 if(Keyboard[0].indexof (strbit[0])! =-1) {//first letter in row one A                     if(Keyboard[0].indexof (ch) = =-1) {//Other letters must also be skipped in the first row otherwise -                          Break; -                     } the}Else if(Keyboard[1].indexof (strbit[0])! =-1) {//The first letter is in the second row . -                     if(Keyboard[1].indexof (ch) = =-1) { -                          Break; -                     } +}Else if(Keyboard[2].indexof (strbit[0])! =-1) {//first letter in row three -                     if(Keyboard[2].indexof (ch) = =-1) { +                          Break; A                     } at                 } -Count + +; -             } -             if(Count = =strbit.length) { - Onerowwords.add (Realword); -             } in         } -string[] Onerowwordsarray =Newstring[onerowwords.size ()]; to          for(inti=0; I<onerowwords.size (); i++){ +Onerowwordsarray[i] =Onerowwords.get (i); -         } the          *         returnOnerowwordsarray; $     }Panax Notoginseng}

Leetcode Keyboard Row500 Java

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.