@@ -0,0 +1,1497 @@
+import java.io.*;%0D%0Aimport java.util.*;%0D%0A%0D%0Apublic class harshitmalik03_Word_Break %7B%0D%0A        public static void main(String%5B%5D args)throws Exception%7B%0D%0A            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));%0D%0A            System.out.println(%22Enter the number of words in the dictionary%22);%0D%0A            int n = Integer.parseInt(br.readLine());%0D%0A//            ArrayList%3CString%3E arr = new ArrayList%3C%3E();%0D%0A            String%5B%5D words ;%0D%0A            System.out.println(%22Enter the words seperated by a space%22);%0D%0A            words = br.readLine().split(%22 %22);%0D%0A            List B = Arrays.asList(words);%0D%0A            System.out.println(%22Enter the sentence%22);%0D%0A            String A = br.readLine();%0D%0A            int val = wordBreak(A, B);%0D%0A            System.out.print(val);%0D%0A        %7D%0D%0A%0D%0A        public static int wordBreak(String A, List B)%7B%0D%0A            int%5B%5D dp = new int%5BA.length()%5D;%0D%0A%0D%0A            for(int i = 0 ; i %3C dp.length ; i++)%7B%0D%0A                for(int j = 0 ; j %3C= i ; j++)%7B%0D%0A                    String toCheck = A.substring(j,i+1);%0D%0A                    if(B.contains(toCheck))%7B%0D%0A                        if(j %3E 0)%7B%0D%0A                            dp%5Bi%5D += dp%5Bj-1%5D;%0D%0A                        %7Delse%7B%0D%0A                            dp%5Bi%5D += 1;%0D%0A                        %7D%0D%0A                    %7D%0D%0A                %7D%0D%0A            %7D%0D%0A            if(dp%5BA.length()-1%5D %3E 0)%7B%0D%0A                return 1;%0D%0A            %7Delse%7B%0D%0A                return 0;%0D%0A            %7D%0D%0A%0D%0A        %7D%0D%0A%0D%0A%7D%0D%0A

Add Word Break Java Code