3839. Number of Prefix Connected Groups
You are given an array of strings
wordsand an integerk.Two words
aandbat distinct indices are prefix-connected ifa[0..k-1] == b[0..k-1].A connected group is a set of words such that each pair of words is prefix-connected.
Return the number of connected groups that contain at least two words, formed from the given words.
Note:
- Words with length less than
kcannot join any group and are ignored.- Duplicate strings are treated as separate words.
1 | class Solution { |