I think the tmp array is not keeping correct frequency of elements and try to maintain a map instead of vector
I think the tmp array is not keeping correct frequency of elements and try to maintain a map instead of vector