Question: I cant do contains part from typing import List def insert ( data , s: str ) - > None: if s = =
I cant do contains part
from typing import List
def insertdata s: str None:
if s :
return
if lens:
if s in data:
datas True
else:
datas True
if s in data:
insertdatas s:
else:
datas False
insertdatas s:
def countwordsdataint:
Returns the number of words encoded in data. You may assume
data is a valid trie.
data
insertdata "test"
insertdata "testing"
insertdata "doc"
insertdata "docs"
insertdata "document"
insertdata "documenting"
countwordsdata
stack listdatavalues
totalcount
while stack:
node stack.pop
if node:
totalcount
stack.extendnodevalues
return totalcount
def containsdata s: str bool:
Returns True if and only if s is encoded within data. You may
assume data is a valid trie.
data
insertdata "tree"
insertdata "trie"
insertdata "try"
insertdata "trying"
containsdata "try"
True
containsdata "trying"
True
containsdata "the"
False
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
