r/programming • • Sep 22 '20

Google engineer breaks down the problems he uses when doing technical interviews. Lots of advice on algorithms and programming.

https://alexgolec.dev/google-interview-questions-deconstructed-the-knights-dialer/
6.4k Upvotes

1.1k comments sorted by

View all comments

Show parent comments

0

u/eterevsky Sep 22 '20

Nope. std::map is based on binary tree and is much less efficient than a hashmap like std::unordered_map. The upside is that it keeps the elements ordered in case you need to iterate over them in order.

3

u/[deleted] Sep 23 '20

Uh, no one said they used C++. A map is implemented as an associative array in a lot of popular languages, if it even exists as a separate thing.

1

u/SFTechFIRE Sep 23 '20

For algorithm coding questions map vs unordered_map doesn't matter because the big O complexity will differ by a logn factor. Unless the grading platform has strict timeouts where the difference between say 100 ms runtime and 1 second runtime is pass/fail.