Two Sum with data structure

We can do Two Sum using

A small modification to O(n) version would get a

  • O(1) find
  • O(1) add
  • O(n) space