Given a document string (containing arbitrary characters: letters, digits, punctuation, etc.) and a list of target words (plain words, no punctuation), perform three tasks: (1) Check whether all target words appear in the document. (2) Count the occurrences of each target word in the document. (3) Find the shortest contiguous…