Replace Words

Given a list of words where the list serves as both dictionary and word list, return how many words have a strictly shorter prefix that also appears in the list. A word never replaces itself and equal length duplicates do not count. Count every word with at least one shorter root present.

Examples
Input: []
Output: 0
Hints

Replace Words

Given a list of words where the list serves as both dictionary and word list, return how many words have a strictly shorter prefix that also appears in the list. A word never replaces itself and equal length duplicates do not count. Count every word with at least one shorter root present.