Maybe a problem of understanding:
In the Question:
"set(key, value) - Set or insert the value if the key is not already present."
=> so I think that means when set with an existing key just ignore it;
The test case:
So step is
2, 2 ignore
4, 4 keep, and drop 3,1
get 2, returns 1;
I think the way to read that is set or (insert the value if the key is not present). If you read it like that, then it means that the new value should override the existing one. If you do this, you will pass the tests.
@cosminBoaca Hi, I have a question. If the new value overrides the value of key "2" in the fourth step, should I increase the frequency of key "2" by 1? or just reset its frequency to 1? Thanks.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.