LeetCode 1408数组中的字符串匹配(java)

    科技2022-08-08  92

    class Solution { public List<String> stringMatching(String[] words) { List<String> res = new ArrayList<>(); if(null == words) return res; String str = String.join("-",words); for(String word : words) { if(str.indexOf(word) != str.lastIndexOf(word)) { res.add(word); } } return res; } }
    Processed: 0.015, SQL: 8