Given an array of N integers containing integers from 1 to N only. Some numbers may appear multiple times, some numbers may not appear.
Write code to print out the count of times each number from 1 to N appears in the array. For example:
PrintFrequency(new int[] {3, 1, 2});
1 : 1
2 : 1
3 : 1
PrintFrequency(new int[] {2, 4, 4, 6, 6, 6});
1 : 0
2 : 1
3 : 0
4 : 2
5 : 0
6 : 3
This problem asks you to count how many times each value from 1 to N appears in the array. The standard solution is to use a frequency array of size N, scan the input once, increment the matching bucket for each value, and then print counts in order from 1 to N. This gives an O(N) time solution with O(N) extra space and is a clean, interview-friendly approach.