This question evaluates algorithmic problem-solving skills involving array processing, counting and combinatorics under conditional constraints and frequency handling.
You are given an array ages, where ages[i] is the age of the i-th person. A person of age A will send a friend request to a person of age B if all conditions hold:
Each request is directed (A→B). A person cannot send a request to themselves.
Return the total number of friend requests that will be sent.
ages
: integer array
ages = [16, 16]
ages = [20, 30, 100, 110, 120]