To solve it, it is convenient to use a hash function that returns a unique value for each row (hash).
C++11 has a built-in facility for getting a hash: hash. < br /> In the future, to count the number of hashes, it is better to use the unordered_map hash table, which also appeared in C++ 11. You can learn more about using map in the course Dynamic data structures -> Associative arrays: map.

An example of getting a hash from the string "test":

hash<string> hash_fn;
size_t str_hash = hash_fn("test" );
cout<<str_hash;


The result will be: "2949673445", so from each unique string you can get a unique hash that can be used as a key in the  unordered_map.

Hashing a string is a representation of a string as some number, unique (we will assume that the chance of a collision is negligible) for each string. This allows you to store any important data (like passwords) in the database not as strings, but as numbers. This allows you to protect passwords if an attacker gains access to the password database, because he will not get the passwords themselves, but only their numerical representation, and it is almost impossible to get a string by its hash (especially without knowing the hashing algorithm). 
Polynomial hashes are most often used in programming competition problems.
One of the best ways to determine the hash function of the string S is as follows:
h(S)  =  S[0]  +  S[1] * P  +  S[2] * P^2  +  S[3] * P^3  +  ...  +  S[N] * P^N