A collector combines stream elements into a result container or an aggregate. Choose the grouping key before choosing the aggregate: tags group by their exact text, while a stock report merges quantities under each SKU. Duplicate keys are expected data here, so toMap needs an explicit merge rule.
The bundled browser library supports groupingBy, toList, summingInt and toMap with a merge function. Its Collectors.counting() implementation is unavailable. On a desktop JDK, groupingBy(key, counting()) is the usual counting form; here you group into lists and read their sizes. The exercises state that boundary and execute the supported equivalent. flatMap turns nested lists into one stream. This browser can retain duplicates when flatMap chains directly into distinct. Collect into a list, then build a TreeSet to remove duplicates and sort. The desktop JDK supports the direct flatMap/distinct chain.