0

I want to be able find the maximum amount of times a substring occurs consecutively , this substring is not already predefined but it can be anything.

public static int countWordsOccurence(String line){
//return the occurence
}

For example inputing "raacdrunrunruntryingtotrackrunrun" would return 3 because run occurs 3 times in a row

Another example inputing "baabugbugbackscarybugbugbug" would also return 3 as well because bug occurs 3 times in a row

Note: This is not like Occurrences of substring in a string because you're not getting an input of the substring you are looking for and also your not counting the occurences but simply the maximum amount of times it occurs in a row.

Ahmed Hussein
  • 715
  • 1
  • 15
  • 38
Tom ros
  • 9
  • 2
  • [Find word with maximum number of occurrences](https://stackoverflow.com/questions/7540351/find-word-with-maximum-number-of-occurrences) – Eng.Fouad Apr 12 '18 at 18:32
  • Didn't you recently ask this? And were requested to show your attempt in your question? – DontKnowMuchBut Getting Better Apr 12 '18 at 18:32
  • 1
    It is not like that because your not counting the maximum occurrences But the maximum occurrences consecutively – Tom ros Apr 12 '18 at 18:37
  • It's not a duplicate. The linked question ... well, as Tom ros pointed out. However, Tom, you don't show us your effort. So maybe it should stay closed until own attempts to solve it are shown. What is your problem? Are you searching for a coder doing the work for you? Is there a minimum size > 1 for the String? Since `run` and `bug` are real words - is there a real word restriction with a dictionary, to look them up? – user unknown Apr 12 '18 at 20:05

0 Answers0