I took a test on CodeSignal but couldn't solve this problem.
Create a data structure that allows the following operations.
insert x y - insert an object with key x and value y.
get x - return the value of an object with key x.
addToKey x - add x to all keys in map
addToValue y -add y to all values in map.
Time complexity of each operation should be O(log(N))
I was able to make a hash map using array and LinkedList in Java. But I wasn't able to make the time complexity to O(log(N)).
In my implementation, the time complexity of insert and get was O(1) (O(N) in worst cases). And the time complexity of addToKey and addToValue was O(N) as I had to iterate all elements to modify keys and values.
What would be a proper data structure for this problem?