From the course: Nail Your Java Interview

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Solution: Find most repeated word

Solution: Find most repeated word - Java Tutorial

From the course: Nail Your Java Interview

Start my 1-month free trial

Solution: Find most repeated word

(upbeat music) - [Instructor] Create a program, that finds the most repeated word in a given string. This is one way to solve the problem, but of course there are many others. First, we set up our test strings with calls to our algorithm, find most repeated word. Looking at this function, we see it takes in a string as input and returns a string, specifically the string that is the most repeated word. The first thing we do here, is normalized the input using a helper function, let's take a look at that. Convert to uncommon words. This function does a few data transformations. First, we trim off the spaces from the sides and convert it to lowercase. Then we take out the delimiters using the split method and convert our input to individual words. Next, we list out the common words we want to ignore, and stream through the input, using the streams API. We filter out the common words, and any words with the length less than…

Contents