美文网首页
2022-03-17 720词典中最长的单词

2022-03-17 720词典中最长的单词

作者: 16孙一凡通工 | 来源:发表于2022-03-17 15:52 被阅读0次

每日打卡

720. 词典中最长的单词

class Solution {
    public String longestWord(String[] words) {
        // List<String>  list=new ArrayList<>();
        // 自排序
        Arrays.sort(words);
      
     
       String[] input=words;
       String res="";
        int n=input.length;
      
        
        Set<String> set=new HashSet<>();
     
        for(String s:input){
            if(s.length()==1 || set.contains(s.substring(0,s.length()-1))){
                res=s.length()>res.length()? s:res;
                set.add(s);
            }
        }
       
        return  res;
        


    }
}

相关文章

  • 2022-03-17 720词典中最长的单词

    每日打卡 720. 词典中最长的单词[https://leetcode-cn.com/problems/longe...

  • 『字典树』词典中最长的单词720

    题目相关 原题链接:720. 词典中最长的单词 - 力扣(LeetCode) 涉及知识:字典树 题目难度:★ 题目...

  • 720. 词典中最长的单词

    内容 给出一个字符串数组words组成的一本英语词典。从中找出最长的一个单词,该单词是由words词典中其他单词逐...

  • Leetcode 720 词典中最长的单词

    词典中最长的单词 题目 给出一个字符串数组words组成的一本英语词典。从中找出最长的一个单词,该单词是由word...

  • 2021-11-23 720. 词典中最长的单词【Easy】

    给出一个字符串数组words组成的一本英语词典。从中找出最长的一个单词,该单词是由words词典中其他单词逐步添加...

  • 133. 最长单词

    给一个词典,找出其中所有最长的单词。样例 在词典{"dog","google","facebook","inter...

  • 单词相关问题总结

    0X00 单词比较问题总结 比较两个单词所用字符是否相同 0X01 单词搜索问题总结 前缀搜索 720. 词典中最...

  • OJ lintcode 最长单词

    给一个词典,找出其中所有最长的单词。您在真实的面试中是否遇到过这个题?Yes样例在词典{"dog","google...

  • Design & Coed 2: 找出最长单词

    找出最长单词 Find the Longest Word in a String 找出最长单词 在句子中找出最长的...

  • rime与rhyme

    rime /raɪm/ 这个单词,在一些比较现代的正式词典中,如剑桥英语词典中,是没有这个单词的解释的。而在国内...

网友评论

      本文标题:2022-03-17 720词典中最长的单词

      本文链接:https://www.haomeiwen.com/subject/cjwvdrtx.html