Function to check if N and K are anagrams
static bool isValid ( long N , int K ) { HashSet < long > m1 = new HashSet < long > ( ) ; HashSet < int > m2 = new HashSet < int > ( ) ; while ( N > 0 ) { m1 . Add ( N % 10 ) ; N /= 10 ; } while ( K > 0 ) { m2 . Add ( K % 10 ) ; K /= 10 ; } if ( m1 . Equals ( m2 ) ) { return true ; } return false ; }