Your error on the map.insert(A[i],i)
is because it wants you to insert the value_type
of the container (a key/value
pair). You are calling insert()
with two parameters and the only matching overloads aren't the ones you want in this case.
You could instead say:
map[A[i]] = i;
or
map.insert(std::make_pair(A[i], i));
or
map.emplace(A[i], i);