Didn't understood point of returning j

why we used return type int instead of void if we were wanting to only store the value in out. Along with that explain me point of returning j

all the occurences are stored in out array
now to print them you need size of out array(count of occurences of key)

here j is size of out array so we need to return j

that is also the reason why we use int as a return type instead of void

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.