count
of size 121 (since ages are from 1 to 120) to store the count of each age.count
array with the frequency of each age from the input ages
array.prefix
of the same size as count
.prefix[i]
contains the sum of counts up to age i
.requests
to store the total number of friend requests.i
from 15 to 120 (since no one under 15 can send friend requests based on the conditions).count[i]
is zero, skip to the next age.i
using the prefix sum array.requests
by adding the number of new requests for age i
.requests
.