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  20 views  Python Coding Problem
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:
 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
 Write a program to check if the given word is Isogram & Pair isogram in python
 Introduction to Python 3.6 & Jupyter Notebook
 python problem 1: find the runnerup score
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 month ago
Recommended books for interview preparation:
Facebook Page
Similar Posts
 Closest Points
 Sum of the Diagonals
 How to design a customer satisfaction survey
 When using Gaussian mixture model, how do you know it is applicable
 Why use feature selection in machine learning
 What is the difference between Kmean and EM? How to decide k
 Explain a probability distribution that is not normal and how to apply that
 Google Data Scientist interview questions with answers
 Count the number of open lockers in school
 Introduction to Sorting Algorithms
Enter your email address to subscribe to this blog and receive notifications of new posts by email.