give string s dictionary string worddict add space s construct sentence word valid dictionary word return possible sentence orderNote word dictionary reuse multiple time segmentation Example 1input s catsanddog worddict catcatsandsanddogoutput cat dogcat sand dogexample 2input s pineapplepenapple worddict applepenapplepenpinepineappleoutput pine apple pen applepineapple pen applepine applepen appleexplanation note allow reuse dictionary wordexample 3input s catsandog worddict catsdogsandandcatoutput constraints1 slength 201 worddictlength 10001 worddictilength 10 worddicti consist lowercase english lettersall string worddict unique