p is the number of tags in tags that start with p (a tag counts as starting with itself).
For every tag, add up the popularity of each of its non-empty prefixes, from the first letter up to the whole tag. Return these totals in the same order as tags.
Duplicate tags are counted separately.tags=["cat", "car", "dog"] → [5, 5, 3]
cat has the prefixes c (shared by 2 tags), ca (2) and cat (1): 2 + 2 + 1 = 5. Same for car. Every prefix of dog belongs to it alone: 1 + 1 + 1 = 3.
tags=["go", "gopher", "g"] → [5, 9, 3]
The prefix g is shared by all three tags, go by two, and the rest of gopher's prefixes by it alone. For go: 3 + 2 = 5; for gopher: 3 + 2 + 1 + 1 + 1 + 1 = 9; for g: 3.
tags=["zz", "zz"] → [4, 4]
tags=["cat", "car", "dog"]
[5, 5, 3]
Run checks the first 3 tests in your browser. Submit checks all 99 tests on the server, hidden ones included.