def get_longest_substring(str):
n = len(str)
l = [[0 for x in range(n + 1)]
for y in range(n + 1)]
res = ""
res_length = 0
idx = 0
for i in range(1, n + 1):
for j in range(i + 1, n + 1):
if (str[i  1] == str[j  1] and
l[i  1][j  1] < (j  i)):
l[i][j] = l[i  1][j  1] + 1
if (l[i][j] > res_length):
res_length = l[i][j]
idx = max(i, idx)
else:
l[i][j] = 0
if (res_length > 0):
for i in range(idx  res_length + 1,idx + 1):
res = res + str[i  1]
return res
print(get_longest_substring("aadaghgdjdjdjaada"))
Write a python program to find Largest Substring that occurs more than once
Carvia Tech  May 04, 2019  1 min read  19 views  Python Coding Problems
Largest Substring
you need to identify the largest substring that occurs more than once within a larger string. You will be given a list of strings. Each string will consist of some random set of lowercase letters of at least one character and at most 100 characters. For example, given the string “abbbcdaabbbczaabbbc” we can identify several substrings that occur more than once:

ab occurs 3 times

bbb occurs 3 times

aabbbc occurs 2 times
aada
Top articles in this category:
 Python coding challenges for interviews
 Python Flask Interview Questions
 Top 100 interview questions on Data Science & Machine Learning
 Google Data Scientist interview questions with answers
 Write a program for Hailstone Sequence in Python
 Write a program to find if a number is Lychrel Number in Python
 Find extra long factorials in python
Find more on this topic:
Machine Learning
Data science, machine learning, python, R, big data, spark, the Jupyter notebook, and much more
Last updated 1 week ago
Recommended books for interview preparation:
Similar Posts
 Python  Get Google Analytics Data
 Installing PySpark with Jupyter notebook on Ubuntu 18.04 LTS
 Python send GMAIL with attachment
 Send rich text multimedia email in Python
 Blueprints in Flask API Development
 Singleton Design Pattern in Python
 SVM after LSTM deep learning model for text classification
 RuntimeError: get_session is not available when using TensorFlow 2.0
 Deploying Keras Model in Production with TensorFlow 2.0
 Python coding challenges for interviews
Provide email address to subscribe to this blog.