private List<String> solution1(String s, Set<String> dict) {
        Map<Integer, List<String>> result = new HashMap<Integer, List<String>>();
        List<String> l = new ArrayList<String>();
        l.add("");
        result.put(0, l);

        for (int i = 1; i <= s.length(); i++) {
            ArrayList<String> list = new ArrayList<String>();
            for (int j = 0; j < i; j++) {
                if (!result.get(j).isEmpty()
                        && dict.contains(s.substring(j, i))) {
                    for (String item : result.get(j)) {
                        list.add((item + " " + s.substring(j, i)).trim());
                    }
                }
            }
            result.put(i, list);
        }
        return result.get(s.length());
    }