From 78e46a06ff42753f07b1e506fe9987578613e817 Mon Sep 17 00:00:00 2001 From: Matej Focko Date: Wed, 28 Feb 2024 12:25:12 +0100 Subject: [PATCH] =?UTF-8?q?feat(cpp):=20implement=20=E2=80=B9collect=5Fcou?= =?UTF-8?q?nt=E2=80=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Matej Focko --- .common/cpp/skeleton.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.common/cpp/skeleton.cpp b/.common/cpp/skeleton.cpp index e8c0d51..f8c1b80 100644 --- a/.common/cpp/skeleton.cpp +++ b/.common/cpp/skeleton.cpp @@ -150,6 +150,19 @@ Container collect(std::size_t size) { collect(c, size); return c; } + +template +std::map collect_count(std::size_t size) { + std::map counts; + + for (auto i = 0u; i < size; ++i) { + T x; + std::cin >> x; + ++counts[x]; + } + + return counts; +} #pragma endregion /* input */ #pragma region math