if I have an array of 10^6 elements. how to store the count of each element. Is there a more efficient way than the map

it is a array of integers

constraints of elements ?

10^18

Either use un-ordered map or the best idea:-

Use a special map created by this guy on codeforces, it is the fastest map ever!

Link:-

if it is 10^9

where is that link not showing

What is the range of the integers? Are they non-negative and \le 10^7?

If this is the case, you can use a frequency table, implemented using an array.

In general cases, you can use an unordered_map which has average complexity of O(1) for insertion/deletion.