News for hackers. Stuff that matters.
Re:LeetCode Two Sum by dottomato on Sunday February 28, 2021 @02:18PM (#26296183)
Actually your C++ solutions is O(N log N) since you are using `std::map`. If you need to remove that extra log factor what you need to use is `std::unordered_map`

std::map::find - http://www.cplusplus.com/reference/map/map/find/

std::unordered_map::find - http://www.cplusplus.com/reference/unordered_map/unordered_m...

Your Golang soln is O(N) still, since maps in Go lang are hashmaps.

dottomato

There are no comments on this comment yet.