What wrong in this code

hi @Adityakumar3112 you can refer to this code https://ide.codingblocks.com/s/272260 it used the same logic. Please note that I have used vector here instead of map because range of elements is from 1->n

@Adityakumar3112 You have initialised the array with a size of 100. But the value of n can be upto 10^5. Your logic is absolutely correct.