#3839
Number of Prefix Connected Groups
specialist · 720 · lc medium +30 · 60.5% accepted · 45 likes · top 59%
Description
Given a string array words and an integer k, two words are prefix-connected when their first k characters are identical. A connected group is a set of mutually prefix-connected words. Return the number of connected groups of size at least two. Words shorter than k characters are excluded, and duplicate strings count as separate words.
Code
1
2
3