java solution. regex.


  • 0
    U
    public String[] findWords(String[] words) {
            List<String> list = new ArrayList<>();
            for(String s : words){
                if(s.toLowerCase().matches("[qwertyuiop]*|[asdfghjkl]*|[zxcvbnm]*")){
                    list.add(s);
                }
            }
            return list.toArray(new String[list.size()]);
        }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.