Mike and Hashtrick probem

How can we make an array of size max(a[i]) as constraints are 10^9. My code works fine otherwise (i.e., when a[i] is small). What change should I make ?
Code link: https://ide.codingblocks.com/s/164026

Hello @raj.bmp.333

Your code runs perfectly on
4
1 2 3 1000000000
This implies that there is no problem in creating an array of size 10^9 as you have created the “hash” array.

You code produces wrong output for
6
1 2 3 1 2 3

The solution
// Mike_And_HashTrick