Java dp  22 lines and beat 90% with comments
This is the medium question "139. Word Break" + a for loop. \nIf the input size of the list is N and the average of the word length is M.\nTo solve Leetcode 139
This is the medium question "139. Word Break" + a for loop. \nIf the input size of the list is N and the average of the word length is M.\nTo solve Leetcode 139, we have two dp approaches:\n1.For each position in a word, we loop through all the words in the List and update the dp arrays.  BigO: N * M * N\n2.For each word, we loop through all the possible sub strings to find a match in the List and update the dp arrays. BigO: N * M * M\nFor this one, since N is bigger than M, so we use the 2nd approach.\n(I have also tried the 1 approach, and I got a ETL).\n\n```\nclass Solution {\n    public List<String> findAllConcatenatedWordsInADict(String[] words) {\n        List<String> result = new ArrayList<>();\n        HashSet<String> set = new HashSet<>();\n        for(String word : words) set.add(word);     \n        for(String word : words) helper(result, set, word);    \n        return result;\n    }    \n    private void helper(List<String> list, HashSet<String> set, String word){\n        if(word.length() == 0) return;\n        boolean[] dp = new boolean[word.length() + 1];\n        dp[0] = true;\n        for(int i = 0; i < word.length(); i++){\n            if(!dp[i]) continue;\n            for(int j = i + 1; j < dp.length; j++){\n                if(i == 0 && j == word.length()) continue;\n                if(set.contains(word.substring(i,j)))dp[j] = true;                 \n            }\n        }            \n        if(dp[dp.length - 1]) list.add(word);       \n    }\n}\n\n\n```
['Dynamic Programming', 'Java']