Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # dominant_substring.py
- def dominant_substring(string):
- curr, subs = '', ''
- for char in string:
- if not curr or string.count(curr+char) > 1:
- curr += char
- else:
- if string.count(curr)*len(curr) > string.count(subs)*len(subs):
- if len(curr) > 1:
- subs = curr
- curr = ''
- return subs
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement