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
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.