Install dependencies:
yarn install
Run:
yarn start
yarn android
Source:
countIdenticalPairs.ts
Run:
yarn test
Algorithm Explanation:
Idea: Count the frequency (frq) of each element using a HashMap (HashTable).
So number of pairs of each distinct value is (frq)C2.