Hashing highest freq


why its not passing any test cases although its running fine ???

if(freq[a[i]]>ans){
            ans=a[i];
        }

this logic is completely wrong
you are comparing array element with freq
which will give wrong ans