Practice/Meta/Leetcode 825. Friends Of Appropriate Ages
CodingOptional
You are building a social network feature that determines whether person A can send a friend request to person B based on their ages. A friend request from person A (with age X) to person B (with age Y) will NOT be sent if any of the following conditions are true:
Given an array of integers representing the ages of people in the network, return the total number of valid friend requests that can be made.
Note that a person cannot send a friend request to themselves, and if person A can send a request to person B, it does not automatically mean person B can send a request to person A.
Example 1:
` Input: ages = [16, 16, 17] Output: 4 Explanation: Valid requests:
Example 2:
` Input: ages = [20, 30, 100, 110, 120] Output: 3 Explanation: Valid requests exist between certain age pairs:
Example 3:
Input: ages = [8, 8, 8, 8] Output: 0 Explanation: For age 8, condition 1 fails: 8 ≤ 0.5 * 8 + 7 = 11, so no valid requests possible