LEARN

Journey to CP

View on GitHub

MAP

Map i.e., Hash Table is a data structure which stores mapped values of given key values, map Library in c++ is somewhat similar to dictionary in python

Some basic functions of map are insertion of key-value pair,deletion of given key value,iteration of data structure

HEADER FILE

use

#include<map>

INITIATING

OPERATIONS

Note : In the above code , the keyword auto automates the task of determining the suitable data type of variable it , the data type of “it” is an iterator to stl::map i.e., map<int,int>::iterator. It does so in compile time , hence not effecting run time of program . it->first : key , it->second : mapped value of given key one key can never map to 2 different values

Time Complexity

Insertion , Deletion , Accessing mapped value take O(log N) time as hash map is implemented using balanced binary trees

practice

For a better understanding try solving this problem Though this might be solved by some other techniques , try solving this using hash maps

go to all topics