Reverse map lookup

前端 未结 8 815
囚心锁ツ
囚心锁ツ 2020-11-30 05:37

I have a 1 to 1 map. What\'s the best way to find keys from values,

i.e.

For examples if the map is this

KEY VALUE

a    1
b    2
c          


        
8条回答
  •  再見小時候
    2020-11-30 06:07

    Say you have a map. Build a second structure, perhaps a map that enables the reverse lookup but avoids doubling the storage overhead, because, using pointers, there's no need to store each X and Y twice. The second structure simply has pointers into the first.

提交回复
热议问题