30 Substring with Concatenation of All Words

30
Substring with Concatenation of All Words
19.6%
Hard
数words
数s.substring
都用HashMap

public class Solution {
    public List findSubstring(String s, String[] words) {
        List rst = new ArrayList();
        if (words.length == 0) return rst;
        int wordLen = words[0].length();
        int subLen = wordLen * words.length;
        HashMap countMap = new HashMap();
        for (String word:words){
            if (countMap.containsKey(word)) countMap.put(word, countMap.get(word) + 1);
            else countMap.put(word, 1);
        }
        for (int i=0; i copyMap = (HashMap)countMap.clone();
            for (int j=0; j

你可能感兴趣的:(30 Substring with Concatenation of All Words)