下班后渴望春天的男RA(无女AP)# Joke - 肚皮舞运动
f*e
1 楼
Say you have a file containing name value pair, such as
foo: bar
a: b
foo: bar
a: c
The file may be huge, but the number of names are limited.
Given a name, find out how many times the name occurs in the file.
It looks to me there is a straight forward solution using hash table:
we preprocess the file, hash each name into the table, and keep the
count. We then use the same table to look up the name occurrence.
This should be programmed in C, so not stl.
foo: bar
a: b
foo: bar
a: c
The file may be huge, but the number of names are limited.
Given a name, find out how many times the name occurs in the file.
It looks to me there is a straight forward solution using hash table:
we preprocess the file, hash each name into the table, and keep the
count. We then use the same table to look up the name occurrence.
This should be programmed in C, so not stl.