Python Trie O(N^2)
```\nfrom collections import defaultdict\nclass TrieNode:\n    def init(self):\n        self.is_word = False\n        self.count = 0\n        self.children = {}
```\nfrom collections import defaultdict\nclass TrieNode:\n    def __init__(self):\n        self.is_word = False\n        self.count = 0\n        self.children = {}\n\t\t\ndef insert(node, word, i, j):\n    node.is_word = True\n    node.count +=1\n    if i >=j:\n        return\n    if word[i] in node.children:\n        insert(node.children[word[i]], word, i+1, j)\n    else:\n        node.children[word[i]] = TrieNode()\n        insert(node.children[word[i]], word, i+1, j)\n        \ndef search(node, word, i, j, mismatch_count, result):\n    if mismatch_count >1:\n        return\n    if node.is_word:\n        if mismatch_count ==1:\n            result[0] += node.count\n    if i>=j:\n        return\n    for child, child_node in node.children.items():\n        if child == word[i]:\n            search(child_node, word, i+1, j, mismatch_count, result)\n        else:\n            search(child_node, word, i+1, j, mismatch_count+1, result)\n    \ndef countSubstrings(s, t):\n    root = TrieNode()  \n    for i in range(len(s)):\n        insert(root, s, i, len(s))\n    result = [0]\n    for i in range(len(t)):\n        search(root, t, i, len(t), 0, result)\n    return result[0]\n
[]