Python – Maximum occurring Substring from list
Sometimes, while working with Python strings, we can have a problem in which we need to check for maximum occurring substring from strings list. This can have application in DNA sequencing in Biology and other application. Lets discuss certain way in which this task can be performed.
Method : Using regex() + groupby() + max() + lambda
The combination of above functionalities can be used to solve this particular problem. In this, we first extract the sequences using regex function. Then the counter grouping is performed using groupby(). The last step is extracting maximum which is done using max() along with lambda function.
The original string is : gfghsisbjknlmkesbestgfgsdcngfgcsdjnisdjnlbestdjsklgfgcdsbestbnjdsgfgdbhisbhsbestdkgfgb The original list is : ['gfg', 'is', 'best'] Maximum frequency substring : gfg