Follow

Rust question 

@schlink I don't do Rust, but I think the most efficient way to do this would be:

1) Initialize an empty dict(string => count)
2) Iterate through the file, and for each string *if* string in keys(dict), dict[string] += 1; *else* dict[string] = 1

Only makes one pass, which seems like it can't possibly be improved since you need to look at every entry.

Sign in to participate in the conversation
CleverLibre Social

CleverLibre Social is an inclusive social instance for open discussion, learning, and community.
All cultures welcome.
Hate speech and harassment strictly forbidden.