<jupyter_start><jupyter_text>This notebook was prepared by [<NAME>](https://github.com/donnemartin). Source and license info is on [GitHub](https://github.com/donnemartin/interactive-coding-challenges).  Challenge Notebook  Problem: Given two strings, find the longest common substring.* [Constraints](Constraints)* [Test Cases](Test-Cases)* [Algorithm](Algorithm)* [Code](Code)* [Unit Test](Unit-Test)* [Solution Notebook](Solution-Notebook)  Constraints* Can we assume the inputs are valid?    * No* Can we assume the strings are ASCII?    * Yes* Is this case sensitive?    * Yes* Is a substring a contiguous block of chars?    * Yes* Do we expect a string as a result?    * Yes* Can we assume this fits memory?    * Yes  Test Cases* str0 or str1 is None -> Exception* str0 or str1 equals 0 -> ''* General casestr0 = 'ABCDEFGHIJ'str1 = 'FOOBCDBCDE'result: 'BCDE'  AlgorithmRefer to the [Solution Notebook]().  If you are stuck and need a hint, the solution notebook's algorithm discussion might be a good place to start.  Code<jupyter_code>class StringCompare(object):

    def longest_common_substr(self, str0, str1):
        # TODO: Implement me
        pass<jupyter_output><empty_output><jupyter_text>Unit Test **The following unit test is expected to fail until you solve the challenge.**<jupyter_code># %load test_longest_common_substr.py
import unittest


class TestLongestCommonSubstr(unittest.TestCase):

    def test_longest_common_substr(self):
        str_comp = StringCompare()
        self.assertRaises(TypeError, str_comp.longest_common_substr, None, None)
        self.assertEqual(str_comp.longest_common_substr('', ''), '')
        str0 = 'ABCDEFGHIJ'
        str1 = 'FOOBCDBCDE'
        expected = 'BCDE'
        self.assertEqual(str_comp.longest_common_substr(str0, str1), expected)
        print('Success: test_longest_common_substr')


def main():
    test = TestLongestCommonSubstr()
    test.test_longest_common_substr()


if __name__ == '__main__':
    main()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10427010923535253, 'fraction_numerical': 0.006454816285998014, 'mean_word_length': 4.505464480874317, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 12, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '127731', 'license': 'Apache-2.0', 'n_tokens_mistral': 632, 'n_tokens_neox': 606, 'n_words': 182, 'path': 'recursion_dynamic/longest_substring/longest_common_substr_challenge.ipynb', 'repo_name': 'rampup01/interactive-coding-challenges', 'size': '2020'}