-
Notifications
You must be signed in to change notification settings - Fork 0
algocpp::array::count
sakamotor edited this page Jul 15, 2023
·
1 revision
algocpp::array::count
(hereafter count
) is a function for fast counting of elements in an array.
Assuming the number of elements is
#include <iostream>
#include <vector>
#include <algocpp/array.hpp>
using namespace std;
int main()
{
vector<int> a = {1, 2, 3, 3};
// 1
cout << algocpp::array::count(a, 1) << endl;
// 2
cout << algocpp::array::count(a, 3) << endl;
// 0
cout << algocpp::array::count(a, 5) << endl;
}