007 Digit Anagrams
Given an array of integers a, count the number of pairs i and j, such that a[i] and a[j] are digit anagrams.
and I don’t need to explain what a anagram is.
first, we need to check the number of pairs in this array, which, of course, are a.length*(a.length - 1) //we can simply use two pointers to get every pair.
for each and every pair, we check if these two are anagram or not.
the way to check if integers are anagram is: get each digit into an array. then sort it(or of you prefer lower time complexity, use hashmap to get the frequency of that char)
Any better ways?

浙公网安备 33010602011771号