

For that, you can split the String on space using a greedy regular expression, so that it can handle multiple white spaces between words. Solution: In order to find duplicate words, we first need to divide the sentence into words. It contains 150 Programming Questions and their Solutions, which is good enough to clear most of the beginner and intermediate programming job interviews. If you are practicing these coding problems for an interview, I also suggest you take a look at the Cracking the Coding Interview book. Directly jumping into a solution without asking a couple of questions may not go well with many interviewers who look for detail-oriented candidates. It's better to get the requirement right of the problem in the beginning even if the interviewer doesn't tell you everything. given String can be null, empty, may or may not contain any duplicate words, but for simplicity, you can assume that sentence will always be in English and only use ASCII characters, alphabets, and numerals, no special character. if the given String is "Java and JavaScript are totally different, JavaScript follows Java" then your program should print "Java" and "JavaScript" because those two are 2 duplicate words from given String. Problem: Write a Java program to print the duplicate words from a given statement e.g.
