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 - Java Tutorial
From the course: Nail Your Java Interview
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
Leveraging stacks as a data structure4m 36s
-
Using queues in technical interviews4m 5s
-
Mastering hash-based structures4m 51s
-
Challenge: Generate binary numbers1m 19s
-
Solution: Generate binary numbers6m 35s
-
Challenge: Matching parentheses1m 5s
-
Solution: Matching parentheses3m 51s
-
Challenge: Find most repeated word2m 16s
-
Solution: Find most repeated word3m 28s
-
-
-