Counting Distinct Integers In An Array With Frequency Analysis
Counting distinct integers in an array: use a frequency array (fr) to keep track of occurrences. If a value is new, increment counter and set fr[a[i]] to 1. Update fr[a[i]] for each occurrence.