Advertisement
here2share

# dominant_substring.py

May 1st, 2018
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.31 KB | None | 0 0
  1. # dominant_substring.py
  2.  
  3. def dominant_substring(string):
  4.     curr, subs = '', ''
  5.     for char in string:
  6.         if not curr or string.count(curr+char) > 1:
  7.             curr += char
  8.         else:
  9.             if string.count(curr)*len(curr) > string.count(subs)*len(subs):
  10.                 if len(curr) > 1:
  11.                     subs = curr
  12.             curr = ''
  13.     return subs
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement